Hi Ray,
BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down.
It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
Regards
TK
Group: DynoMotion |
Message: 3614 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Tom,
Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Ray,
> Â
> BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> Â
> So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down.
> Â
> It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> Â
> Regards
> TK
> Â
> Â
> Â
> Â
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, January 30, 2012 4:14 PM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Brad,
>
> As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> >
> > Ray,
> >
> >
> >
> > I thought the main issue we were working on was the printf's/PComm issues in
> > your user programs, has that situation improved at all?
> >
> >
> >
> > Good that your MDI code works though.
> >
> >
> >
> > -Brad
> >
> >
> >
> > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > Behalf Of himykabibble
> > Sent: Monday, January 30, 2012 11:24 AM
> > To: DynoMotion@yahoogroups.com
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> >
> >
> >
> > Brad,
> >
> > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > still get the hangs in CheckIsRead() when I have the console callback
> > updating the TextBox, even though it is now also being invoked.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > "bradodarb" <bradodarb@> wrote:
> > >
> > >
> > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > components, but in my case an HTML button is being clicked, handled by
> > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > using some [STAThread ] component..
> > >
> > >
> > > So Ray, surround your calls in an invoke clause as well and see if it
> > improves.
> > >
> > > Here is a nice tidy way to do it::
> > >
> > > public void UpdateDocument(Action action)
> > > {
> > > if (_GuiHost.Parent.InvokeRequired)
> > > {
> > > _GuiHost.Parent.Invoke(action);
> > > }
> > > else
> > > {
> > > action();
> > > }
> > >
> > > And then in your code that runs the CompileAndLoad, etc.. ::
> > >
> > > UpdateDocument(new Action(delegate()
> > > {
> > > //Your existing code inside here
> > > }
> > > ));
> > >
> > > Let me know if this helps.
> > >
> > > -Brad Murry
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > Brad Murry <bradodarb@> wrote:
> > > >
> > > > Hello Ray,
> > > >
> > > >
> > > >
> > > > You should invoke it to your textbox.
> > > >
> > > >
> > > >
> > > > In related news, I have no issues running any of my previously
> > problematic
> > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > >
> > > >
> > > >
> > > > -Brad Murry
> > > >
> > > >
> > > >
> > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > On
> > > > Behalf Of himykabibble
> > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Brad,
> > > >
> > > > I wired in the console message handler, and I now get frequent lock-ups.
> > My
> > > > handler does nothing more than one line of code that stuffs the String
> > > > argument into a TextBox. With that one line commented out, all is good.
> > But
> > > > if I uncomment that one line, then I get frequent hangs - the app just
> > locks
> > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > entirely. The callback does work as it should, until the app locks up.
> > Is
> > > > this a threading thing? Nobody else writes to that TextBox.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > "himykabibble" <jagboy@> wrote:
> > > > >
> > > > > Brad,
> > > > >
> > > > > Well it makes me happy to see someone besides me having strange things
> > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > will
> > > > fix mine as well.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > ,
> > > > Brad Murry <bradodarb@> wrote:
> > > > > >
> > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > it
> > > > only
> > > > > > crashes when I use the InvokeAction.
> > > > > >
> > > > > >
> > > > > >
> > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > look
> > > > at
> > > > > > the Ccode, it populates the MCodeActions as fires the button
> > commands as
> > > > if
> > > > > > they were any other MCode.
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > CompileAndLoadCoff.
> > > > > >
> > > > > >
> > > > > >
> > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > try
> > > > > > that and get back to you.
> > > > > >
> > > > > >
> > > > > >
> > > > > > -Brad
> > > > > >
> > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > On
> > > > > > Behalf Of himykabibble
> > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > didn't
> > > > > > even know how to, but now I do! Cool!).
> > > > > >
> > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > InvokeAction a
> > > > > > better way to do it?
> > > > > >
> > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > Non-motion
> > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > never
> > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > E-stop
> > > > > > button, or re-starting the App, THEN I get the completed callback.
> > So
> > > > > > something is blocking something there as well. This was working fine
> > > > until I
> > > > > > fixed the original PCComm problem.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Hello Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I am wondering if there are some .net memory sharing issues going
> > on
> > > > here.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I just set one of my user buttons to fire off the print.c program
> > and
> > > > I
> > > > > > get
> > > > > > > the same result.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Do you have the message event wired up? -
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > _Controller.MessageUpdated += new
> > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > crash.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > It is interesting to note that we get the print messages just fine
> > > > from
> > > > > > the
> > > > > > > c# console application.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > So I tried this code in my button event handler as a quick and
> > dirty
> > > > > > test::
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > Programs\KMotionCNC\print.c";
> > > > > > >
> > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > TheCFile, false));
> > > > > > >
> > > > > > > //Excecute the program we just loaded
> > > > > > >
> > > > > > > _Controller.WriteLine("Execute1");
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > here.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > as
> > > > well?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Tom,
> > > > > > >
> > > > > > > I know this is a stupid question, but is there some interaction or
> > > > shared
> > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > had
> > > > some
> > > > > > > printfs in the Home code that I had put in while beating on this
> > > > thing. I
> > > > > > > just took them out, and it's now working. Nothing else has
> > changed.
> > > > > > printfs
> > > > > > > still do not come out in the KMotion console after I re-start my
> > app,
> > > > so
> > > > > > > there is something still not completely right, but PCComm is now
> > > > working,
> > > > > > so
> > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > really
> > > > > > > consider the DSP Code, because it's always worked under
> > KMotionCNC....
> > > > > > >
> > > > > > > What could cause KMotion to be able to talk to the board just
> > fine,
> > > > but
> > > > > > NOT
> > > > > > > see printfs? For that matter, when in that state, it does not see
> > DSP
> > > > > > tasks
> > > > > > > running either, as indficated as there are no green highlights on
> > the
> > > > task
> > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > without
> > > > > > > restarting my app, all is well.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Tom,
> > > > > > > >
> > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > KMotionCNC.
> > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > >
> > > > > > > > main()
> > > > > > > > {
> > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > printf("MsgBox Done\n");
> > > > > > > > }
> > > > > > > >
> > > > > > > > This gives a different result. The first printf appears every
> > time.
> > > > The
> > > > > > > second one never appears. My app does not crash or behave
> > strangely in
> > > > any
> > > > > > > way that I can see, even if I open and close it several times.
> > But, if
> > > > I
> > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > KMotion
> > > > > > will
> > > > > > > still be able to talk to the board, and execute commands from the
> > > > console,
> > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > until I
> > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > >
> > > > > > > > I will try to narrow down what in the Home program is
> > influencing
> > > > the
> > > > > > > PCComm stuff. But what could that program be doing that it
> > wouldn't be
> > > > > > doing
> > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > >
> > > > > > > > I'll post the code tomorrow.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > TK <tk@> wrote:
> > > > > > > > >
> > > > > > > > > Hi Ray,
> > > > > > > > >
> > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > more
> > > > like a
> > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > it
> > > > do
> > > > > > > after it sees the persist var cleared? What if you clear it from
> > the
> > > > > > KMotion
> > > > > > > Console instead? Otherwise I can look at if you post all the code.
> >
> > > > > > > >
> > > > > > > > >
> > > > > > > > > TK
> > > > > > > > >
> > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > >
> > > > > > > > > > Tom/Brad,
> > > > > > > > > >
> > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > on
> > > > how
> > > > > > to
> > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > just
> > > > > > fine.
> > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > it
> > > > seems
> > > > > > to
> > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > code
> > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > that,
> > > > > > the
> > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > run
> > > > the
> > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > even
> > > > > > though
> > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > opens
> > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > no
> > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > having
> > > > both
> > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > reluctant
> > > > > > > to try to get 2008 working in that context, for fear it will screw
> > up
> > > > > > 2010,
> > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > build
> > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > >
> > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > not
> > > > the
> > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > that
> > > > is
> > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > wrong,
> > > > > > or
> > > > > > > how, and have had no success in trying to narrow it down. If I
> > comment
> > > > out
> > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > problem
> > > > > > > goes away entirely, and everything works perfectly. If I change
> > that
> > > > one
> > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > "signature"
> > > > > > > changes - rather than crashing almost immediately after the
> > Persist
> > > > > > location
> > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > >
> > > > > > > > > > But, if I then re-start the app without first disconnecting
> > and
> > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > the
> > > > new
> > > > > > app
> > > > > > > instance recognizes the connection is available, and does its
> > > > > > KM_Controller
> > > > > > > initialization. I've stepped through all the init code and the
> > > > > > constructors
> > > > > > > on that second start-up, and whatever is going wrong is going
> > wrong
> > > > AFTER
> > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > would
> > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > >
> > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > shifted
> > > > > > > it from Var 100 to 80), the problem follows it to the new
> > location. So
> > > > > > it's
> > > > > > > not the specific location that's at issue, it has to be something
> > > > > > connected
> > > > > > > with that functionality. But we know the DSP side works fine, and
> > the
> > > > PC
> > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > word. So
> > > > > > > what the heck is really happening?
> > > > > > > > > >
> > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > surrounded
> > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > token
> > > > > > (the
> > > > > > > functions for doing Gather operations do use the token, but those
> > are
> > > > > > > commented out now).
> > > > > > > > > >
> > > > > > > > > > At the point where it's crashing, there are three threads
> > > > running:
> > > > > > > > > > 1) The main app thread
> > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > (which
> > > > > > is
> > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > >
> > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > rate,
> > > > mostly
> > > > > > > for periodically testing the connection, and updating the
> > "connected"
> > > > LED
> > > > > > in
> > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > checkboxes.
> > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > methods
> > > > > > are
> > > > > > > very simple and lightweight.
> > > > > > > > > >
> > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > that
> > > > would
> > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3615 |
From: bradodarb |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Ray,
It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
Let me know if that works for you as well.
-Brad Murry
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Tom,
>
> Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
>
> Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Ray,
> > Â
> > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > Â
> > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down.
> > Â
> > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > Â
> > Regards
> > TK
> > Â
> > Â
> > Â
> > Â
> > From: himykabibble <jagboy@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Monday, January 30, 2012 4:14 PM
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> > Â
> > Brad,
> >
> > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > >
> > > Ray,
> > >
> > >
> > >
> > > I thought the main issue we were working on was the printf's/PComm issues in
> > > your user programs, has that situation improved at all?
> > >
> > >
> > >
> > > Good that your MDI code works though.
> > >
> > >
> > >
> > > -Brad
> > >
> > >
> > >
> > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > Behalf Of himykabibble
> > > Sent: Monday, January 30, 2012 11:24 AM
> > > To: DynoMotion@yahoogroups.com
> > > Subject: [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > >
> > >
> > >
> > > Brad,
> > >
> > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > still get the hangs in CheckIsRead() when I have the console callback
> > > updating the TextBox, even though it is now also being invoked.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > "bradodarb" <bradodarb@> wrote:
> > > >
> > > >
> > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > components, but in my case an HTML button is being clicked, handled by
> > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > using some [STAThread ] component..
> > > >
> > > >
> > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > improves.
> > > >
> > > > Here is a nice tidy way to do it::
> > > >
> > > > public void UpdateDocument(Action action)
> > > > {
> > > > if (_GuiHost.Parent.InvokeRequired)
> > > > {
> > > > _GuiHost.Parent.Invoke(action);
> > > > }
> > > > else
> > > > {
> > > > action();
> > > > }
> > > >
> > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > >
> > > > UpdateDocument(new Action(delegate()
> > > > {
> > > > //Your existing code inside here
> > > > }
> > > > ));
> > > >
> > > > Let me know if this helps.
> > > >
> > > > -Brad Murry
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > Brad Murry <bradodarb@> wrote:
> > > > >
> > > > > Hello Ray,
> > > > >
> > > > >
> > > > >
> > > > > You should invoke it to your textbox.
> > > > >
> > > > >
> > > > >
> > > > > In related news, I have no issues running any of my previously
> > > problematic
> > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > >
> > > > >
> > > > >
> > > > > -Brad Murry
> > > > >
> > > > >
> > > > >
> > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > On
> > > > > Behalf Of himykabibble
> > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Brad,
> > > > >
> > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > My
> > > > > handler does nothing more than one line of code that stuffs the String
> > > > > argument into a TextBox. With that one line commented out, all is good.
> > > But
> > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > locks
> > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > entirely. The callback does work as it should, until the app locks up.
> > > Is
> > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > "himykabibble" <jagboy@> wrote:
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > will
> > > > > fix mine as well.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > ,
> > > > > Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > it
> > > > > only
> > > > > > > crashes when I use the InvokeAction.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > look
> > > > > at
> > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > commands as
> > > > > if
> > > > > > > they were any other MCode.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > CompileAndLoadCoff.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > try
> > > > > > > that and get back to you.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > didn't
> > > > > > > even know how to, but now I do! Cool!).
> > > > > > >
> > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > InvokeAction a
> > > > > > > better way to do it?
> > > > > > >
> > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > Non-motion
> > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > never
> > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > E-stop
> > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > So
> > > > > > > something is blocking something there as well. This was working fine
> > > > > until I
> > > > > > > fixed the original PCComm problem.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Hello Ray,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > on
> > > > > here.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > and
> > > > > I
> > > > > > > get
> > > > > > > > the same result.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Do you have the message event wired up? -
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > crash.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > from
> > > > > > > the
> > > > > > > > c# console application.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > So I tried this code in my button event handler as a quick and
> > > dirty
> > > > > > > test::
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > >
> > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > TheCFile, false));
> > > > > > > >
> > > > > > > > //Excecute the program we just loaded
> > > > > > > >
> > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > here.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > as
> > > > > well?
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > To: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Tom,
> > > > > > > >
> > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > shared
> > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > had
> > > > > some
> > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > thing. I
> > > > > > > > just took them out, and it's now working. Nothing else has
> > > changed.
> > > > > > > printfs
> > > > > > > > still do not come out in the KMotion console after I re-start my
> > > app,
> > > > > so
> > > > > > > > there is something still not completely right, but PCComm is now
> > > > > working,
> > > > > > > so
> > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > really
> > > > > > > > consider the DSP Code, because it's always worked under
> > > KMotionCNC....
> > > > > > > >
> > > > > > > > What could cause KMotion to be able to talk to the board just
> > > fine,
> > > > > but
> > > > > > > NOT
> > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > DSP
> > > > > > > tasks
> > > > > > > > running either, as indficated as there are no green highlights on
> > > the
> > > > > task
> > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > without
> > > > > > > > restarting my app, all is well.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > >
> > > > > > > > > Tom,
> > > > > > > > >
> > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > KMotionCNC.
> > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > >
> > > > > > > > > main()
> > > > > > > > > {
> > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > This gives a different result. The first printf appears every
> > > time.
> > > > > The
> > > > > > > > second one never appears. My app does not crash or behave
> > > strangely in
> > > > > any
> > > > > > > > way that I can see, even if I open and close it several times.
> > > But, if
> > > > > I
> > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > KMotion
> > > > > > > will
> > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > console,
> > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > until I
> > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > >
> > > > > > > > > I will try to narrow down what in the Home program is
> > > influencing
> > > > > the
> > > > > > > > PCComm stuff. But what could that program be doing that it
> > > wouldn't be
> > > > > > > doing
> > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > >
> > > > > > > > > I'll post the code tomorrow.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > TK <tk@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hi Ray,
> > > > > > > > > >
> > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > more
> > > > > like a
> > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > it
> > > > > do
> > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > the
> > > > > > > KMotion
> > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > >
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > TK
> > > > > > > > > >
> > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > > Tom/Brad,
> > > > > > > > > > >
> > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > on
> > > > > how
> > > > > > > to
> > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > just
> > > > > > > fine.
> > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > it
> > > > > seems
> > > > > > > to
> > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > code
> > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > that,
> > > > > > > the
> > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > run
> > > > > the
> > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > even
> > > > > > > though
> > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > opens
> > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > no
> > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > having
> > > > > both
> > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > reluctant
> > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > up
> > > > > > > 2010,
> > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > build
> > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > >
> > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > not
> > > > > the
> > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > that
> > > > > is
> > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > wrong,
> > > > > > > or
> > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > comment
> > > > > out
> > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > problem
> > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > that
> > > > > one
> > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > "signature"
> > > > > > > > changes - rather than crashing almost immediately after the
> > > Persist
> > > > > > > location
> > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > >
> > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > and
> > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > the
> > > > > new
> > > > > > > app
> > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > KM_Controller
> > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > constructors
> > > > > > > > on that second start-up, and whatever is going wrong is going
> > > wrong
> > > > > AFTER
> > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > would
> > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > >
> > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > shifted
> > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > location. So
> > > > > > > it's
> > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > connected
> > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > the
> > > > > PC
> > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > word. So
> > > > > > > > what the heck is really happening?
> > > > > > > > > > >
> > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > surrounded
> > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > token
> > > > > > > (the
> > > > > > > > functions for doing Gather operations do use the token, but those
> > > are
> > > > > > > > commented out now).
> > > > > > > > > > >
> > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > running:
> > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > (which
> > > > > > > is
> > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > >
> > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > rate,
> > > > > mostly
> > > > > > > > for periodically testing the connection, and updating the
> > > "connected"
> > > > > LED
> > > > > > > in
> > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > checkboxes.
> > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > methods
> > > > > > > are
> > > > > > > > very simple and lightweight.
> > > > > > > > > > >
> > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > that
> > > > > would
> > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3616 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Brad,
ALL of my DSP programs are now started via invoke, and I still have the problem.
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@...> wrote:
>
> Ray,
>
> It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
>
>
> So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
>
> I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
>
> Let me know if that works for you as well.
>
> -Brad Murry
>
>
> --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> >
> > Tom,
> >
> > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> >
> > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Ray,
> > > Â
> > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > Â
> > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > Â
> > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > Â
> > > Regards
> > > TK
> > > Â
> > > Â
> > > Â
> > > Â
> > > From: himykabibble <jagboy@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Monday, January 30, 2012 4:14 PM
> > > Subject: [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > > Â
> > > Brad,
> > >
> > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > >
> > > > Ray,
> > > >
> > > >
> > > >
> > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > your user programs, has that situation improved at all?
> > > >
> > > >
> > > >
> > > > Good that your MDI code works though.
> > > >
> > > >
> > > >
> > > > -Brad
> > > >
> > > >
> > > >
> > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > Behalf Of himykabibble
> > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > To: DynoMotion@yahoogroups.com
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Brad,
> > > >
> > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > updating the TextBox, even though it is now also being invoked.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > "bradodarb" <bradodarb@> wrote:
> > > > >
> > > > >
> > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > components, but in my case an HTML button is being clicked, handled by
> > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > using some [STAThread ] component..
> > > > >
> > > > >
> > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > improves.
> > > > >
> > > > > Here is a nice tidy way to do it::
> > > > >
> > > > > public void UpdateDocument(Action action)
> > > > > {
> > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > {
> > > > > _GuiHost.Parent.Invoke(action);
> > > > > }
> > > > > else
> > > > > {
> > > > > action();
> > > > > }
> > > > >
> > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > >
> > > > > UpdateDocument(new Action(delegate()
> > > > > {
> > > > > //Your existing code inside here
> > > > > }
> > > > > ));
> > > > >
> > > > > Let me know if this helps.
> > > > >
> > > > > -Brad Murry
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > Brad Murry <bradodarb@> wrote:
> > > > > >
> > > > > > Hello Ray,
> > > > > >
> > > > > >
> > > > > >
> > > > > > You should invoke it to your textbox.
> > > > > >
> > > > > >
> > > > > >
> > > > > > In related news, I have no issues running any of my previously
> > > > problematic
> > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > >
> > > > > >
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > >
> > > > > >
> > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > On
> > > > > > Behalf Of himykabibble
> > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > My
> > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > But
> > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > locks
> > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > Is
> > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > will
> > > > > > fix mine as well.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > ,
> > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > it
> > > > > > only
> > > > > > > > crashes when I use the InvokeAction.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > look
> > > > > > at
> > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > commands as
> > > > > > if
> > > > > > > > they were any other MCode.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > CompileAndLoadCoff.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > try
> > > > > > > > that and get back to you.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > didn't
> > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > >
> > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > InvokeAction a
> > > > > > > > better way to do it?
> > > > > > > >
> > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > Non-motion
> > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > never
> > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > E-stop
> > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > So
> > > > > > > > something is blocking something there as well. This was working fine
> > > > > > until I
> > > > > > > > fixed the original PCComm problem.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Hello Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > on
> > > > > > here.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > and
> > > > > > I
> > > > > > > > get
> > > > > > > > > the same result.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Do you have the message event wired up? -
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > crash.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > from
> > > > > > > > the
> > > > > > > > > c# console application.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > dirty
> > > > > > > > test::
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > >
> > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > TheCFile, false));
> > > > > > > > >
> > > > > > > > > //Excecute the program we just loaded
> > > > > > > > >
> > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > here.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > as
> > > > > > well?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Tom,
> > > > > > > > >
> > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > shared
> > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > had
> > > > > > some
> > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > thing. I
> > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > changed.
> > > > > > > > printfs
> > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > app,
> > > > > > so
> > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > working,
> > > > > > > > so
> > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > really
> > > > > > > > > consider the DSP Code, because it's always worked under
> > > > KMotionCNC....
> > > > > > > > >
> > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > fine,
> > > > > > but
> > > > > > > > NOT
> > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > DSP
> > > > > > > > tasks
> > > > > > > > > running either, as indficated as there are no green highlights on
> > > > the
> > > > > > task
> > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > without
> > > > > > > > > restarting my app, all is well.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > Tom,
> > > > > > > > > >
> > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > KMotionCNC.
> > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > >
> > > > > > > > > > main()
> > > > > > > > > > {
> > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > This gives a different result. The first printf appears every
> > > > time.
> > > > > > The
> > > > > > > > > second one never appears. My app does not crash or behave
> > > > strangely in
> > > > > > any
> > > > > > > > > way that I can see, even if I open and close it several times.
> > > > But, if
> > > > > > I
> > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > KMotion
> > > > > > > > will
> > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > console,
> > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > until I
> > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > >
> > > > > > > > > > I will try to narrow down what in the Home program is
> > > > influencing
> > > > > > the
> > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > wouldn't be
> > > > > > > > doing
> > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > >
> > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hi Ray,
> > > > > > > > > > >
> > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > more
> > > > > > like a
> > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > it
> > > > > > do
> > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > the
> > > > > > > > KMotion
> > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > >
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > TK
> > > > > > > > > > >
> > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > on
> > > > > > how
> > > > > > > > to
> > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > just
> > > > > > > > fine.
> > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > it
> > > > > > seems
> > > > > > > > to
> > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > code
> > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > that,
> > > > > > > > the
> > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > run
> > > > > > the
> > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > even
> > > > > > > > though
> > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > opens
> > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > no
> > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > having
> > > > > > both
> > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > reluctant
> > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > up
> > > > > > > > 2010,
> > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > build
> > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > >
> > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > not
> > > > > > the
> > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > that
> > > > > > is
> > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > wrong,
> > > > > > > > or
> > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > comment
> > > > > > out
> > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > problem
> > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > that
> > > > > > one
> > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > "signature"
> > > > > > > > > changes - rather than crashing almost immediately after the
> > > > Persist
> > > > > > > > location
> > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > >
> > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > and
> > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > the
> > > > > > new
> > > > > > > > app
> > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > KM_Controller
> > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > constructors
> > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > wrong
> > > > > > AFTER
> > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > would
> > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > >
> > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > shifted
> > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > location. So
> > > > > > > > it's
> > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > connected
> > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > the
> > > > > > PC
> > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > word. So
> > > > > > > > > what the heck is really happening?
> > > > > > > > > > > >
> > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > surrounded
> > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > token
> > > > > > > > (the
> > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > are
> > > > > > > > > commented out now).
> > > > > > > > > > > >
> > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > running:
> > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > (which
> > > > > > > > is
> > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > >
> > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > rate,
> > > > > > mostly
> > > > > > > > > for periodically testing the connection, and updating the
> > > > "connected"
> > > > > > LED
> > > > > > > > in
> > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > checkboxes.
> > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > methods
> > > > > > > > are
> > > > > > > > > very simple and lightweight.
> > > > > > > > > > > >
> > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > that
> > > > > > would
> > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3617 |
From: Tom Kerekes |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Hi Ray/Brad,
I don't think starting DSP programs is the issue.
I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
About every other time the application locks up in what appears to me to probably be a classic deadlock. One Thread did a WriteLineReadLine which resulted in a Console Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
Maybe Brad can explain his understanding of this Invoke stuff. Does the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
I'm thinking the ConsoleCallback should never do any GUI stuff. Any thread might have called the KMotion Libraries to do something and end up calling the callback.
Regards
TK
Group: DynoMotion |
Message: 3618 |
From: bradodarb |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Hello Ray,
I will look into your code then, as regrettably I cannot reproduce the same problems in my codebase.
-Brad Murry
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Brad,
>
> ALL of my DSP programs are now started via invoke, and I still have the problem.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> >
> > Ray,
> >
> > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> >
> >
> > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> >
> > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> >
> > Let me know if that works for you as well.
> >
> > -Brad Murry
> >
> >
> > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > >
> > > Tom,
> > >
> > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > >
> > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > >
> > > > Hi Ray,
> > > > Â
> > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > Â
> > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > Â
> > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > Â
> > > > Regards
> > > > TK
> > > > Â
> > > > Â
> > > > Â
> > > > Â
> > > > From: himykabibble <jagboy@>
> > > > To: DynoMotion@yahoogroups.com
> > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > > Â
> > > > Brad,
> > > >
> > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > >
> > > > > Ray,
> > > > >
> > > > >
> > > > >
> > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > your user programs, has that situation improved at all?
> > > > >
> > > > >
> > > > >
> > > > > Good that your MDI code works though.
> > > > >
> > > > >
> > > > >
> > > > > -Brad
> > > > >
> > > > >
> > > > >
> > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > Behalf Of himykabibble
> > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Brad,
> > > > >
> > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > updating the TextBox, even though it is now also being invoked.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > "bradodarb" <bradodarb@> wrote:
> > > > > >
> > > > > >
> > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > using some [STAThread ] component..
> > > > > >
> > > > > >
> > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > improves.
> > > > > >
> > > > > > Here is a nice tidy way to do it::
> > > > > >
> > > > > > public void UpdateDocument(Action action)
> > > > > > {
> > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > {
> > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > }
> > > > > > else
> > > > > > {
> > > > > > action();
> > > > > > }
> > > > > >
> > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > >
> > > > > > UpdateDocument(new Action(delegate()
> > > > > > {
> > > > > > //Your existing code inside here
> > > > > > }
> > > > > > ));
> > > > > >
> > > > > > Let me know if this helps.
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Hello Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > You should invoke it to your textbox.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > In related news, I have no issues running any of my previously
> > > > > problematic
> > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > My
> > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > But
> > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > locks
> > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > Is
> > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > will
> > > > > > > fix mine as well.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > it
> > > > > > > only
> > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > look
> > > > > > > at
> > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > commands as
> > > > > > > if
> > > > > > > > > they were any other MCode.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > CompileAndLoadCoff.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > try
> > > > > > > > > that and get back to you.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > didn't
> > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > >
> > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > InvokeAction a
> > > > > > > > > better way to do it?
> > > > > > > > >
> > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > Non-motion
> > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > never
> > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > E-stop
> > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > So
> > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > until I
> > > > > > > > > fixed the original PCComm problem.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hello Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > on
> > > > > > > here.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > and
> > > > > > > I
> > > > > > > > > get
> > > > > > > > > > the same result.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > crash.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > from
> > > > > > > > > the
> > > > > > > > > > c# console application.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > dirty
> > > > > > > > > test::
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > >
> > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > TheCFile, false));
> > > > > > > > > >
> > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > >
> > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > here.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > as
> > > > > > > well?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Tom,
> > > > > > > > > >
> > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > shared
> > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > had
> > > > > > > some
> > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > thing. I
> > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > changed.
> > > > > > > > > printfs
> > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > app,
> > > > > > > so
> > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > working,
> > > > > > > > > so
> > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > really
> > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > KMotionCNC....
> > > > > > > > > >
> > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > fine,
> > > > > > > but
> > > > > > > > > NOT
> > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > DSP
> > > > > > > > > tasks
> > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > the
> > > > > > > task
> > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > without
> > > > > > > > > > restarting my app, all is well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Tom,
> > > > > > > > > > >
> > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > KMotionCNC.
> > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > >
> > > > > > > > > > > main()
> > > > > > > > > > > {
> > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > time.
> > > > > > > The
> > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > strangely in
> > > > > > > any
> > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > But, if
> > > > > > > I
> > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > KMotion
> > > > > > > > > will
> > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > console,
> > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > until I
> > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > >
> > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > influencing
> > > > > > > the
> > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > wouldn't be
> > > > > > > > > doing
> > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > >
> > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > >
> > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > more
> > > > > > > like a
> > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > it
> > > > > > > do
> > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > the
> > > > > > > > > KMotion
> > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > >
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > TK
> > > > > > > > > > > >
> > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > on
> > > > > > > how
> > > > > > > > > to
> > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > just
> > > > > > > > > fine.
> > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > it
> > > > > > > seems
> > > > > > > > > to
> > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > code
> > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > that,
> > > > > > > > > the
> > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > run
> > > > > > > the
> > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > even
> > > > > > > > > though
> > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > opens
> > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > no
> > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > having
> > > > > > > both
> > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > reluctant
> > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > up
> > > > > > > > > 2010,
> > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > build
> > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > not
> > > > > > > the
> > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > that
> > > > > > > is
> > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > wrong,
> > > > > > > > > or
> > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > comment
> > > > > > > out
> > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > problem
> > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > that
> > > > > > > one
> > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > "signature"
> > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > Persist
> > > > > > > > > location
> > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > >
> > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > and
> > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > the
> > > > > > > new
> > > > > > > > > app
> > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > KM_Controller
> > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > constructors
> > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > wrong
> > > > > > > AFTER
> > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > would
> > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > shifted
> > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > location. So
> > > > > > > > > it's
> > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > connected
> > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > the
> > > > > > > PC
> > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > word. So
> > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > surrounded
> > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > token
> > > > > > > > > (the
> > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > are
> > > > > > > > > > commented out now).
> > > > > > > > > > > > >
> > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > running:
> > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > (which
> > > > > > > > > is
> > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > >
> > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > rate,
> > > > > > > mostly
> > > > > > > > > > for periodically testing the connection, and updating the
> > > > > "connected"
> > > > > > > LED
> > > > > > > > > in
> > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > checkboxes.
> > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > methods
> > > > > > > > > are
> > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > that
> > > > > > > would
> > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3619 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Tom,
That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Ray/Brad,
> Â
> I don't think starting DSP programs is the issue.
> Â
> I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> Â
> About every other time the application locks up in what appears to me to probably be a classic deadlock.  One Thread did a WriteLineReadLine which resulted in a Console Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> Â
> Maybe Brad can explain his understanding of this Invoke stuff. Does the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> Â
> I'm thinking the ConsoleCallback should never do any GUI stuff. Any thread might have called the KMotion Libraries to do something and end up calling the callback.
> Â
> Regards
> TK
> Â
>
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, January 30, 2012 5:51 PM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Brad,
>
> ALL of my DSP programs are now started via invoke, and I still have the problem.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> >
> > Ray,
> >
> > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> >
> >
> > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> >
> > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> >
> > Let me know if that works for you as well.
> >
> > -Brad Murry
> >
> >
> > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > >
> > > Tom,
> > >
> > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > >
> > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > >
> > > > Hi Ray,
> > > > ÃÂ
> > > > BTW the DSP printfs send unsolicited messages to the PC.ÃÂ Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃÂ In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > ÃÂ
> > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃÂ Maybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > ÃÂ
> > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > ÃÂ
> > > > Regards
> > > > TK
> > > > ÃÂ
> > > > ÃÂ
> > > > ÃÂ
> > > > ÃÂ
> > > > From: himykabibble <jagboy@>
> > > > To: DynoMotion@yahoogroups.com
> > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > > ÃÂ
> > > > Brad,
> > > >
> > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > >
> > > > > Ray,
> > > > >
> > > > >
> > > > >
> > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > your user programs, has that situation improved at all?
> > > > >
> > > > >
> > > > >
> > > > > Good that your MDI code works though.
> > > > >
> > > > >
> > > > >
> > > > > -Brad
> > > > >
> > > > >
> > > > >
> > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > Behalf Of himykabibble
> > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Brad,
> > > > >
> > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > updating the TextBox, even though it is now also being invoked.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > "bradodarb" <bradodarb@> wrote:
> > > > > >
> > > > > >
> > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > using some [STAThread ] component..
> > > > > >
> > > > > >
> > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > improves.
> > > > > >
> > > > > > Here is a nice tidy way to do it::
> > > > > >
> > > > > > public void UpdateDocument(Action action)
> > > > > > {
> > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > {
> > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > }
> > > > > > else
> > > > > > {
> > > > > > action();
> > > > > > }
> > > > > >
> > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > >
> > > > > > UpdateDocument(new Action(delegate()
> > > > > > {
> > > > > > //Your existing code inside here
> > > > > > }
> > > > > > ));
> > > > > >
> > > > > > Let me know if this helps.
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Hello Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > You should invoke it to your textbox.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > In related news, I have no issues running any of my previously
> > > > > problematic
> > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > My
> > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > But
> > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > locks
> > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > Is
> > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > will
> > > > > > > fix mine as well.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > it
> > > > > > > only
> > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > look
> > > > > > > at
> > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > commands as
> > > > > > > if
> > > > > > > > > they were any other MCode.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > CompileAndLoadCoff.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > try
> > > > > > > > > that and get back to you.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > didn't
> > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > >
> > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > InvokeAction a
> > > > > > > > > better way to do it?
> > > > > > > > >
> > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > Non-motion
> > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > never
> > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > E-stop
> > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > So
> > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > until I
> > > > > > > > > fixed the original PCComm problem.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hello Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > on
> > > > > > > here.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > and
> > > > > > > I
> > > > > > > > > get
> > > > > > > > > > the same result.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > crash.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > from
> > > > > > > > > the
> > > > > > > > > > c# console application.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > dirty
> > > > > > > > > test::
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > >
> > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > TheCFile, false));
> > > > > > > > > >
> > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > >
> > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > here.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > as
> > > > > > > well?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Tom,
> > > > > > > > > >
> > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > shared
> > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > had
> > > > > > > some
> > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > thing. I
> > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > changed.
> > > > > > > > > printfs
> > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > app,
> > > > > > > so
> > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > working,
> > > > > > > > > so
> > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > really
> > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > KMotionCNC....
> > > > > > > > > >
> > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > fine,
> > > > > > > but
> > > > > > > > > NOT
> > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > DSP
> > > > > > > > > tasks
> > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > the
> > > > > > > task
> > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > without
> > > > > > > > > > restarting my app, all is well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Tom,
> > > > > > > > > > >
> > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > KMotionCNC.
> > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > >
> > > > > > > > > > > main()
> > > > > > > > > > > {
> > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > time.
> > > > > > > The
> > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > strangely in
> > > > > > > any
> > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > But, if
> > > > > > > I
> > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > KMotion
> > > > > > > > > will
> > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > console,
> > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > until I
> > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > >
> > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > influencing
> > > > > > > the
> > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > wouldn't be
> > > > > > > > > doing
> > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > >
> > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > >
> > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > more
> > > > > > > like a
> > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > it
> > > > > > > do
> > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > the
> > > > > > > > > KMotion
> > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > >
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > TK
> > > > > > > > > > > >
> > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > on
> > > > > > > how
> > > > > > > > > to
> > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > just
> > > > > > > > > fine.
> > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > it
> > > > > > > seems
> > > > > > > > > to
> > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > code
> > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > that,
> > > > > > > > > the
> > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > run
> > > > > > > the
> > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > even
> > > > > > > > > though
> > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > opens
> > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > no
> > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > having
> > > > > > > both
> > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > reluctant
> > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > up
> > > > > > > > > 2010,
> > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > build
> > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > not
> > > > > > > the
> > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > that
> > > > > > > is
> > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > wrong,
> > > > > > > > > or
> > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > comment
> > > > > > > out
> > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > problem
> > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > that
> > > > > > > one
> > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > "signature"
> > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > Persist
> > > > > > > > > location
> > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > >
> > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > and
> > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > the
> > > > > > > new
> > > > > > > > > app
> > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > KM_Controller
> > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > constructors
> > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > wrong
> > > > > > > AFTER
> > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > would
> > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > shifted
> > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > location. So
> > > > > > > > > it's
> > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > connected
> > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > the
> > > > > > > PC
> > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > word. So
> > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > surrounded
> > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > token
> > > > > > > > > (the
> > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > are
> > > > > > > > > > commented out now).
> > > > > > > > > > > > >
> > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > running:
> > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > (which
> > > > > > > > > is
> > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > >
> > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > rate,
> > > > > > > mostly
> > > > > > > > > > for periodically testing the connection, and updating the
> > > > > "connected"
> > > > > > > LED
> > > > > > > > > in
> > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > checkboxes.
> > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > methods
> > > > > > > > > are
> > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > that
> > > > > > > would
> > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3620 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Brad,
Let me refresh it one more time. It's now in a state where the failure is quite consistent, which will make it easier to find.
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@...> wrote:
>
>
> Hello Ray,
>
> I will look into your code then, as regrettably I cannot reproduce the same problems in my codebase.
>
> -Brad Murry
>
> --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> >
> > Brad,
> >
> > ALL of my DSP programs are now started via invoke, and I still have the problem.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > >
> > > Ray,
> > >
> > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > >
> > >
> > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > >
> > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > >
> > > Let me know if that works for you as well.
> > >
> > > -Brad Murry
> > >
> > >
> > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > >
> > > > Tom,
> > > >
> > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > >
> > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > Hi Ray,
> > > > > Â
> > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > Â
> > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > Â
> > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > Â
> > > > > Regards
> > > > > TK
> > > > > Â
> > > > > Â
> > > > > Â
> > > > > Â
> > > > > From: himykabibble <jagboy@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > Â
> > > > > Brad,
> > > > >
> > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > >
> > > > > > Ray,
> > > > > >
> > > > > >
> > > > > >
> > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > your user programs, has that situation improved at all?
> > > > > >
> > > > > >
> > > > > >
> > > > > > Good that your MDI code works though.
> > > > > >
> > > > > >
> > > > > >
> > > > > > -Brad
> > > > > >
> > > > > >
> > > > > >
> > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > Behalf Of himykabibble
> > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > >
> > > > > > >
> > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > using some [STAThread ] component..
> > > > > > >
> > > > > > >
> > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > improves.
> > > > > > >
> > > > > > > Here is a nice tidy way to do it::
> > > > > > >
> > > > > > > public void UpdateDocument(Action action)
> > > > > > > {
> > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > {
> > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > }
> > > > > > > else
> > > > > > > {
> > > > > > > action();
> > > > > > > }
> > > > > > >
> > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > >
> > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > {
> > > > > > > //Your existing code inside here
> > > > > > > }
> > > > > > > ));
> > > > > > >
> > > > > > > Let me know if this helps.
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Hello Ray,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > You should invoke it to your textbox.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > In related news, I have no issues running any of my previously
> > > > > > problematic
> > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > My
> > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > But
> > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > locks
> > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > Is
> > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > will
> > > > > > > > fix mine as well.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ,
> > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > it
> > > > > > > > only
> > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > look
> > > > > > > > at
> > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > commands as
> > > > > > > > if
> > > > > > > > > > they were any other MCode.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > try
> > > > > > > > > > that and get back to you.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > didn't
> > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > >
> > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > InvokeAction a
> > > > > > > > > > better way to do it?
> > > > > > > > > >
> > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > Non-motion
> > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > never
> > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > E-stop
> > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > So
> > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > until I
> > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hello Ray,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > on
> > > > > > > > here.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > and
> > > > > > > > I
> > > > > > > > > > get
> > > > > > > > > > > the same result.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > crash.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > from
> > > > > > > > > > the
> > > > > > > > > > > c# console application.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > dirty
> > > > > > > > > > test::
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > >
> > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > TheCFile, false));
> > > > > > > > > > >
> > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > >
> > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > here.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > as
> > > > > > > > well?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Tom,
> > > > > > > > > > >
> > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > shared
> > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > had
> > > > > > > > some
> > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > thing. I
> > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > changed.
> > > > > > > > > > printfs
> > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > app,
> > > > > > > > so
> > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > working,
> > > > > > > > > > so
> > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > really
> > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > KMotionCNC....
> > > > > > > > > > >
> > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > fine,
> > > > > > > > but
> > > > > > > > > > NOT
> > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > DSP
> > > > > > > > > > tasks
> > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > the
> > > > > > > > task
> > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > without
> > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > KMotionCNC.
> > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > >
> > > > > > > > > > > > main()
> > > > > > > > > > > > {
> > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > time.
> > > > > > > > The
> > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > strangely in
> > > > > > > > any
> > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > But, if
> > > > > > > > I
> > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > KMotion
> > > > > > > > > > will
> > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > console,
> > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > until I
> > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > >
> > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > influencing
> > > > > > > > the
> > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > wouldn't be
> > > > > > > > > > doing
> > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > >
> > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > >
> > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > more
> > > > > > > > like a
> > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > it
> > > > > > > > do
> > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > the
> > > > > > > > > > KMotion
> > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > TK
> > > > > > > > > > > > >
> > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > on
> > > > > > > > how
> > > > > > > > > > to
> > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > just
> > > > > > > > > > fine.
> > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > it
> > > > > > > > seems
> > > > > > > > > > to
> > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > code
> > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > that,
> > > > > > > > > > the
> > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > run
> > > > > > > > the
> > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > even
> > > > > > > > > > though
> > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > opens
> > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > no
> > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > having
> > > > > > > > both
> > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > reluctant
> > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > up
> > > > > > > > > > 2010,
> > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > build
> > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > not
> > > > > > > > the
> > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > that
> > > > > > > > is
> > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > wrong,
> > > > > > > > > > or
> > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > comment
> > > > > > > > out
> > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > problem
> > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > that
> > > > > > > > one
> > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > "signature"
> > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > Persist
> > > > > > > > > > location
> > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > and
> > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > the
> > > > > > > > new
> > > > > > > > > > app
> > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > KM_Controller
> > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > constructors
> > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > wrong
> > > > > > > > AFTER
> > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > would
> > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > shifted
> > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > location. So
> > > > > > > > > > it's
> > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > connected
> > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > the
> > > > > > > > PC
> > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > word. So
> > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > surrounded
> > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > token
> > > > > > > > > > (the
> > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > are
> > > > > > > > > > > commented out now).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > running:
> > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > (which
> > > > > > > > > > is
> > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > rate,
> > > > > > > > mostly
> > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > "connected"
> > > > > > > > LED
> > > > > > > > > > in
> > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > checkboxes.
> > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > methods
> > > > > > > > > > are
> > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > that
> > > > > > > > would
> > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3621 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Brad,
There's a fresh zip file in RayLs Files. It seems fairly stable as long as the console message handler is commented out. If it's not, then it hangs frequently. It's at the very bottom of ProgramRunPage-EventHandlers.cs.
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Brad,
>
> Let me refresh it one more time. It's now in a state where the failure is quite consistent, which will make it easier to find.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> >
> >
> > Hello Ray,
> >
> > I will look into your code then, as regrettably I cannot reproduce the same problems in my codebase.
> >
> > -Brad Murry
> >
> > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > >
> > > Brad,
> > >
> > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > >
> > > > Ray,
> > > >
> > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > >
> > > >
> > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > >
> > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > >
> > > > Let me know if that works for you as well.
> > > >
> > > > -Brad Murry
> > > >
> > > >
> > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > >
> > > > > Tom,
> > > > >
> > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > >
> > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > > Hi Ray,
> > > > > > Â
> > > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > Â
> > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > Â
> > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > Â
> > > > > > Regards
> > > > > > TK
> > > > > > Â
> > > > > > Â
> > > > > > Â
> > > > > > Â
> > > > > > From: himykabibble <jagboy@>
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > Â
> > > > > > Brad,
> > > > > >
> > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > your user programs, has that situation improved at all?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Good that your MDI code works though.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > using some [STAThread ] component..
> > > > > > > >
> > > > > > > >
> > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > improves.
> > > > > > > >
> > > > > > > > Here is a nice tidy way to do it::
> > > > > > > >
> > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > {
> > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > {
> > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > }
> > > > > > > > else
> > > > > > > > {
> > > > > > > > action();
> > > > > > > > }
> > > > > > > >
> > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > >
> > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > {
> > > > > > > > //Your existing code inside here
> > > > > > > > }
> > > > > > > > ));
> > > > > > > >
> > > > > > > > Let me know if this helps.
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Hello Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > You should invoke it to your textbox.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > problematic
> > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > My
> > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > But
> > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > locks
> > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > Is
> > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > will
> > > > > > > > > fix mine as well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > it
> > > > > > > > > only
> > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > look
> > > > > > > > > at
> > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > commands as
> > > > > > > > > if
> > > > > > > > > > > they were any other MCode.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > try
> > > > > > > > > > > that and get back to you.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > didn't
> > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > >
> > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > InvokeAction a
> > > > > > > > > > > better way to do it?
> > > > > > > > > > >
> > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > Non-motion
> > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > never
> > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > E-stop
> > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > So
> > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > until I
> > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > on
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > and
> > > > > > > > > I
> > > > > > > > > > > get
> > > > > > > > > > > > the same result.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > crash.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > from
> > > > > > > > > > > the
> > > > > > > > > > > > c# console application.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > dirty
> > > > > > > > > > > test::
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > >
> > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > >
> > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > as
> > > > > > > > > well?
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > shared
> > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > had
> > > > > > > > > some
> > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > thing. I
> > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > changed.
> > > > > > > > > > > printfs
> > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > app,
> > > > > > > > > so
> > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > working,
> > > > > > > > > > > so
> > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > really
> > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > KMotionCNC....
> > > > > > > > > > > >
> > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > fine,
> > > > > > > > > but
> > > > > > > > > > > NOT
> > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > DSP
> > > > > > > > > > > tasks
> > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > the
> > > > > > > > > task
> > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > without
> > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Tom,
> > > > > > > > > > > > >
> > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > >
> > > > > > > > > > > > > main()
> > > > > > > > > > > > > {
> > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > time.
> > > > > > > > > The
> > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > strangely in
> > > > > > > > > any
> > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > But, if
> > > > > > > > > I
> > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > KMotion
> > > > > > > > > > > will
> > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > console,
> > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > until I
> > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > influencing
> > > > > > > > > the
> > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > wouldn't be
> > > > > > > > > > > doing
> > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > more
> > > > > > > > > like a
> > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > it
> > > > > > > > > do
> > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > the
> > > > > > > > > > > KMotion
> > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > TK
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > on
> > > > > > > > > how
> > > > > > > > > > > to
> > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > just
> > > > > > > > > > > fine.
> > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > it
> > > > > > > > > seems
> > > > > > > > > > > to
> > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > code
> > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > that,
> > > > > > > > > > > the
> > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > run
> > > > > > > > > the
> > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > even
> > > > > > > > > > > though
> > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > opens
> > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > no
> > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > having
> > > > > > > > > both
> > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > reluctant
> > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > up
> > > > > > > > > > > 2010,
> > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > build
> > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > not
> > > > > > > > > the
> > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > that
> > > > > > > > > is
> > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > wrong,
> > > > > > > > > > > or
> > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > comment
> > > > > > > > > out
> > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > problem
> > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > that
> > > > > > > > > one
> > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > "signature"
> > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > Persist
> > > > > > > > > > > location
> > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > and
> > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > the
> > > > > > > > > new
> > > > > > > > > > > app
> > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > KM_Controller
> > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > constructors
> > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > wrong
> > > > > > > > > AFTER
> > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > would
> > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > shifted
> > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > location. So
> > > > > > > > > > > it's
> > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > connected
> > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > the
> > > > > > > > > PC
> > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > word. So
> > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > surrounded
> > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > token
> > > > > > > > > > > (the
> > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > are
> > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > running:
> > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > (which
> > > > > > > > > > > is
> > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > rate,
> > > > > > > > > mostly
> > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > "connected"
> > > > > > > > > LED
> > > > > > > > > > > in
> > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > checkboxes.
> > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > methods
> > > > > > > > > > > are
> > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > that
> > > > > > > > > would
> > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3622 |
From: Tom Kerekes |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Ray, Here is your deadlock situation
Main Thread
DisplayTimer Tick
Service KFLOP Commands
GetPersistVar(100)
WriteLineReadLine
WorkerThread
UpdateControls
GetCommandedSpindleRPM()
GetPersistVarAsFloat
WriteLineReadLine
OnKMCallback
OnMessage
KMController_ConsoleMessageHandler
ConsoleMessageHandlerCallback
UpdateDocument( new Action( delegate()
ProgramRunPageForm.Invoke(action);
Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
TK
Group: DynoMotion |
Message: 3623 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Tom,
That makes sense! VS2010 Express does not seem to have that option to view threads.
So what do I do about this? Seems like I could kick off a worker thread to handle the console messages, but is that the right thing to do?
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Ray, Here is your deadlock situation
> Â
> Main Thread
> Â Â DisplayTimer Tick
> Â Â Â Â Â Service KFLOP Commands
> Â Â Â Â Â Â Â Â GetPersistVar(100)
> Â Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> Â
> WorkerThread
> Â Â UpdateControls
> Â Â Â Â Â GetCommandedSpindleRPM()
> Â Â Â Â Â Â GetPersistVarAsFloat
> Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
>             OnKMCallback                OnMessage                  KMController_ConsoleMessageHandler                      ConsoleMessageHandlerCallback                        UpdateDocument(                            ProgramRunPageForm.Invoke(action);newAction( delegate()
> Â Â Â Â Â
> Â
> Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> Â
> BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> Â
> TK
> Â
> Â
> Â
> Â
> Â
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, January 30, 2012 6:31 PM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Tom,
>
> That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Ray/Brad,
> > ÃÂ
> > I don't think starting DSP programs is the issue.
> > ÃÂ
> > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > ÃÂ
> > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃÂ ÃÂ One Thread did a WriteLineReadLine which resulted in aÃÂ Console Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > ÃÂ
> > Maybe Brad can explain his understanding of this Invoke stuff.ÃÂ Does the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > ÃÂ
> > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃÂ Any thread might have called the KMotion Libraries to do something and end up calling the callback.
> > ÃÂ
> > Regards
> > TK
> > ÃÂ
> >
> > From: himykabibble <jagboy@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Monday, January 30, 2012 5:51 PM
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> > ÃÂ
> > Brad,
> >
> > ALL of my DSP programs are now started via invoke, and I still have the problem.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > >
> > > Ray,
> > >
> > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > >
> > >
> > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > >
> > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > >
> > > Let me know if that works for you as well.
> > >
> > > -Brad Murry
> > >
> > >
> > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > >
> > > > Tom,
> > > >
> > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > >
> > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > Hi Ray,
> > > > > ÃâÃÂ
> > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > ÃâÃÂ
> > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > ÃâÃÂ
> > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > ÃâÃÂ
> > > > > Regards
> > > > > TK
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > From: himykabibble <jagboy@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > ÃâÃÂ
> > > > > Brad,
> > > > >
> > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > >
> > > > > > Ray,
> > > > > >
> > > > > >
> > > > > >
> > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > your user programs, has that situation improved at all?
> > > > > >
> > > > > >
> > > > > >
> > > > > > Good that your MDI code works though.
> > > > > >
> > > > > >
> > > > > >
> > > > > > -Brad
> > > > > >
> > > > > >
> > > > > >
> > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > Behalf Of himykabibble
> > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > >
> > > > > > >
> > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > using some [STAThread ] component..
> > > > > > >
> > > > > > >
> > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > improves.
> > > > > > >
> > > > > > > Here is a nice tidy way to do it::
> > > > > > >
> > > > > > > public void UpdateDocument(Action action)
> > > > > > > {
> > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > {
> > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > }
> > > > > > > else
> > > > > > > {
> > > > > > > action();
> > > > > > > }
> > > > > > >
> > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > >
> > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > {
> > > > > > > //Your existing code inside here
> > > > > > > }
> > > > > > > ));
> > > > > > >
> > > > > > > Let me know if this helps.
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Hello Ray,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > You should invoke it to your textbox.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > In related news, I have no issues running any of my previously
> > > > > > problematic
> > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > My
> > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > But
> > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > locks
> > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > Is
> > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > will
> > > > > > > > fix mine as well.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ,
> > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > it
> > > > > > > > only
> > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > look
> > > > > > > > at
> > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > commands as
> > > > > > > > if
> > > > > > > > > > they were any other MCode.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > try
> > > > > > > > > > that and get back to you.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > didn't
> > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > >
> > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > InvokeAction a
> > > > > > > > > > better way to do it?
> > > > > > > > > >
> > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > Non-motion
> > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > never
> > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > E-stop
> > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > So
> > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > until I
> > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hello Ray,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > on
> > > > > > > > here.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > and
> > > > > > > > I
> > > > > > > > > > get
> > > > > > > > > > > the same result.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > crash.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > from
> > > > > > > > > > the
> > > > > > > > > > > c# console application.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > dirty
> > > > > > > > > > test::
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > >
> > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > TheCFile, false));
> > > > > > > > > > >
> > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > >
> > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > here.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > as
> > > > > > > > well?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Tom,
> > > > > > > > > > >
> > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > shared
> > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > had
> > > > > > > > some
> > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > thing. I
> > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > changed.
> > > > > > > > > > printfs
> > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > app,
> > > > > > > > so
> > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > working,
> > > > > > > > > > so
> > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > really
> > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > KMotionCNC....
> > > > > > > > > > >
> > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > fine,
> > > > > > > > but
> > > > > > > > > > NOT
> > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > DSP
> > > > > > > > > > tasks
> > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > the
> > > > > > > > task
> > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > without
> > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > KMotionCNC.
> > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > >
> > > > > > > > > > > > main()
> > > > > > > > > > > > {
> > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > time.
> > > > > > > > The
> > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > strangely in
> > > > > > > > any
> > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > But, if
> > > > > > > > I
> > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > KMotion
> > > > > > > > > > will
> > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > console,
> > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > until I
> > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > >
> > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > influencing
> > > > > > > > the
> > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > wouldn't be
> > > > > > > > > > doing
> > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > >
> > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > >
> > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > more
> > > > > > > > like a
> > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > it
> > > > > > > > do
> > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > the
> > > > > > > > > > KMotion
> > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > TK
> > > > > > > > > > > > >
> > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > on
> > > > > > > > how
> > > > > > > > > > to
> > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > just
> > > > > > > > > > fine.
> > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > it
> > > > > > > > seems
> > > > > > > > > > to
> > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > code
> > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > that,
> > > > > > > > > > the
> > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > run
> > > > > > > > the
> > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > even
> > > > > > > > > > though
> > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > opens
> > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > no
> > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > having
> > > > > > > > both
> > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > reluctant
> > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > up
> > > > > > > > > > 2010,
> > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > build
> > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > not
> > > > > > > > the
> > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > that
> > > > > > > > is
> > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > wrong,
> > > > > > > > > > or
> > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > comment
> > > > > > > > out
> > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > problem
> > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > that
> > > > > > > > one
> > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > "signature"
> > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > Persist
> > > > > > > > > > location
> > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > and
> > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > the
> > > > > > > > new
> > > > > > > > > > app
> > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > KM_Controller
> > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > constructors
> > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > wrong
> > > > > > > > AFTER
> > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > would
> > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > shifted
> > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > location. So
> > > > > > > > > > it's
> > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > connected
> > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > the
> > > > > > > > PC
> > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > word. So
> > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > surrounded
> > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > token
> > > > > > > > > > (the
> > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > are
> > > > > > > > > > > commented out now).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > running:
> > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > (which
> > > > > > > > > > is
> > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > rate,
> > > > > > > > mostly
> > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > "connected"
> > > > > > > > LED
> > > > > > > > > > in
> > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > checkboxes.
> > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > methods
> > > > > > > > > > are
> > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > that
> > > > > > > > would
> > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3624 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Ray, Here is your deadlock situation
> Â
> Main Thread
> Â Â DisplayTimer Tick
> Â Â Â Â Â Service KFLOP Commands
> Â Â Â Â Â Â Â Â GetPersistVar(100)
> Â Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> Â
> WorkerThread
> Â Â UpdateControls
> Â Â Â Â Â GetCommandedSpindleRPM()
> Â Â Â Â Â Â GetPersistVarAsFloat
> Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
>             OnKMCallback                OnMessage                  KMController_ConsoleMessageHandler                      ConsoleMessageHandlerCallback                        UpdateDocument(                            ProgramRunPageForm.Invoke(action);newAction( delegate()
> Â Â Â Â Â
> Â
> Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> Â
> BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> Â
> TK
> Â
> Â
> Â
> Â
> Â
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, January 30, 2012 6:31 PM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Tom,
>
> That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Ray/Brad,
> > ÃÂ
> > I don't think starting DSP programs is the issue.
> > ÃÂ
> > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > ÃÂ
> > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃÂ ÃÂ One Thread did a WriteLineReadLine which resulted in aÃÂ Console Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > ÃÂ
> > Maybe Brad can explain his understanding of this Invoke stuff.ÃÂ Does the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > ÃÂ
> > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃÂ Any thread might have called the KMotion Libraries to do something and end up calling the callback.
> > ÃÂ
> > Regards
> > TK
> > ÃÂ
> >
> > From: himykabibble <jagboy@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Monday, January 30, 2012 5:51 PM
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> > ÃÂ
> > Brad,
> >
> > ALL of my DSP programs are now started via invoke, and I still have the problem.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > >
> > > Ray,
> > >
> > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > >
> > >
> > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > >
> > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > >
> > > Let me know if that works for you as well.
> > >
> > > -Brad Murry
> > >
> > >
> > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > >
> > > > Tom,
> > > >
> > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > >
> > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > Hi Ray,
> > > > > ÃâÃÂ
> > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > ÃâÃÂ
> > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > ÃâÃÂ
> > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > ÃâÃÂ
> > > > > Regards
> > > > > TK
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > From: himykabibble <jagboy@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > ÃâÃÂ
> > > > > Brad,
> > > > >
> > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > >
> > > > > > Ray,
> > > > > >
> > > > > >
> > > > > >
> > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > your user programs, has that situation improved at all?
> > > > > >
> > > > > >
> > > > > >
> > > > > > Good that your MDI code works though.
> > > > > >
> > > > > >
> > > > > >
> > > > > > -Brad
> > > > > >
> > > > > >
> > > > > >
> > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > Behalf Of himykabibble
> > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > >
> > > > > > >
> > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > using some [STAThread ] component..
> > > > > > >
> > > > > > >
> > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > improves.
> > > > > > >
> > > > > > > Here is a nice tidy way to do it::
> > > > > > >
> > > > > > > public void UpdateDocument(Action action)
> > > > > > > {
> > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > {
> > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > }
> > > > > > > else
> > > > > > > {
> > > > > > > action();
> > > > > > > }
> > > > > > >
> > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > >
> > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > {
> > > > > > > //Your existing code inside here
> > > > > > > }
> > > > > > > ));
> > > > > > >
> > > > > > > Let me know if this helps.
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Hello Ray,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > You should invoke it to your textbox.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > In related news, I have no issues running any of my previously
> > > > > > problematic
> > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > My
> > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > But
> > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > locks
> > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > Is
> > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > will
> > > > > > > > fix mine as well.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ,
> > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > it
> > > > > > > > only
> > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > look
> > > > > > > > at
> > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > commands as
> > > > > > > > if
> > > > > > > > > > they were any other MCode.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > try
> > > > > > > > > > that and get back to you.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > didn't
> > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > >
> > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > InvokeAction a
> > > > > > > > > > better way to do it?
> > > > > > > > > >
> > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > Non-motion
> > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > never
> > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > E-stop
> > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > So
> > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > until I
> > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hello Ray,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > on
> > > > > > > > here.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > and
> > > > > > > > I
> > > > > > > > > > get
> > > > > > > > > > > the same result.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > crash.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > from
> > > > > > > > > > the
> > > > > > > > > > > c# console application.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > dirty
> > > > > > > > > > test::
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > >
> > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > TheCFile, false));
> > > > > > > > > > >
> > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > >
> > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > here.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > as
> > > > > > > > well?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Tom,
> > > > > > > > > > >
> > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > shared
> > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > had
> > > > > > > > some
> > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > thing. I
> > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > changed.
> > > > > > > > > > printfs
> > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > app,
> > > > > > > > so
> > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > working,
> > > > > > > > > > so
> > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > really
> > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > KMotionCNC....
> > > > > > > > > > >
> > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > fine,
> > > > > > > > but
> > > > > > > > > > NOT
> > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > DSP
> > > > > > > > > > tasks
> > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > the
> > > > > > > > task
> > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > without
> > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > KMotionCNC.
> > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > >
> > > > > > > > > > > > main()
> > > > > > > > > > > > {
> > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > time.
> > > > > > > > The
> > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > strangely in
> > > > > > > > any
> > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > But, if
> > > > > > > > I
> > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > KMotion
> > > > > > > > > > will
> > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > console,
> > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > until I
> > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > >
> > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > influencing
> > > > > > > > the
> > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > wouldn't be
> > > > > > > > > > doing
> > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > >
> > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > >
> > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > more
> > > > > > > > like a
> > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > it
> > > > > > > > do
> > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > the
> > > > > > > > > > KMotion
> > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > TK
> > > > > > > > > > > > >
> > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > on
> > > > > > > > how
> > > > > > > > > > to
> > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > just
> > > > > > > > > > fine.
> > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > it
> > > > > > > > seems
> > > > > > > > > > to
> > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > code
> > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > that,
> > > > > > > > > > the
> > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > run
> > > > > > > > the
> > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > even
> > > > > > > > > > though
> > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > opens
> > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > no
> > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > having
> > > > > > > > both
> > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > reluctant
> > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > up
> > > > > > > > > > 2010,
> > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > build
> > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > not
> > > > > > > > the
> > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > that
> > > > > > > > is
> > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > wrong,
> > > > > > > > > > or
> > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > comment
> > > > > > > > out
> > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > problem
> > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > that
> > > > > > > > one
> > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > "signature"
> > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > Persist
> > > > > > > > > > location
> > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > and
> > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > the
> > > > > > > > new
> > > > > > > > > > app
> > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > KM_Controller
> > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > constructors
> > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > wrong
> > > > > > > > AFTER
> > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > would
> > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > shifted
> > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > location. So
> > > > > > > > > > it's
> > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > connected
> > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > the
> > > > > > > > PC
> > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > word. So
> > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > surrounded
> > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > token
> > > > > > > > > > (the
> > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > are
> > > > > > > > > > > commented out now).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > running:
> > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > (which
> > > > > > > > > > is
> > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > rate,
> > > > > > > > mostly
> > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > "connected"
> > > > > > > > LED
> > > > > > > > > > in
> > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > checkboxes.
> > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > methods
> > > > > > > > > > are
> > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > that
> > > > > > > > would
> > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3625 |
From: Tom Kerekes |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
No I think more threads would make things worse. I'm curious what Brad thinks. But the only thing I can think of is to make a FIFO of console messages. So the ConsoleCallback can always just push the message someplace and return. Then another thread or one of your existing Threads can later pull the message from the FIFO and display it while it does not have KFLOP locked. BTW if you do take this approach the FIFO must be Thread Safe which probably means a Mutex around it. Otherwise something might happen like one thread is in the process of reading out a string and gets pre-empted, then the other Thread decides to push a string in but there isn't enough space so it re-allocates (moves) the memory or something similar. I think a single Thread
handling the GUI would simplify things a lot.
TK
Group: DynoMotion |
Message: 3626 |
From: bradodarb |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
I saw the deadlock as well. You also had timers competing with your worker thread.
I got rid of all timers and re-routed the synchronous calls that were competing for the Kflop (and GUI) as Tom pointed out.
I will upload your modified source.
-Brad
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Ray, Here is your deadlock situation
> > Â
> > Main Thread
> > Â Â DisplayTimer Tick
> > Â Â Â Â Â Service KFLOP Commands
> > Â Â Â Â Â Â Â Â GetPersistVar(100)
> > Â Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> > Â
> > WorkerThread
> > Â Â UpdateControls
> > Â Â Â Â Â GetCommandedSpindleRPM()
> > Â Â Â Â Â Â GetPersistVarAsFloat
> > Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> >             OnKMCallback                OnMessage                  KMController_ConsoleMessageHandler                      ConsoleMessageHandlerCallback                        UpdateDocument(                            ProgramRunPageForm.Invoke(action);newAction( delegate()
> > Â Â Â Â Â
> > Â
> > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > Â
> > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > Â
> > TK
> > Â
> > Â
> > Â
> > Â
> > Â
> > From: himykabibble <jagboy@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Monday, January 30, 2012 6:31 PM
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> > Â
> > Tom,
> >
> > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Ray/Brad,
> > > ÃÂ
> > > I don't think starting DSP programs is the issue.
> > > ÃÂ
> > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > ÃÂ
> > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃÂ ÃÂ One Thread did a WriteLineReadLine which resulted in aÃÂ Console Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > ÃÂ
> > > Maybe Brad can explain his understanding of this Invoke stuff.ÃÂ Does the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > ÃÂ
> > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃÂ Any thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > ÃÂ
> > > Regards
> > > TK
> > > ÃÂ
> > >
> > > From: himykabibble <jagboy@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Monday, January 30, 2012 5:51 PM
> > > Subject: [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > > ÃÂ
> > > Brad,
> > >
> > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > >
> > > > Ray,
> > > >
> > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > >
> > > >
> > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > >
> > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > >
> > > > Let me know if that works for you as well.
> > > >
> > > > -Brad Murry
> > > >
> > > >
> > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > >
> > > > > Tom,
> > > > >
> > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > >
> > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > > Hi Ray,
> > > > > > ÃâÃÂ
> > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > ÃâÃÂ
> > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > ÃâÃÂ
> > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > ÃâÃÂ
> > > > > > Regards
> > > > > > TK
> > > > > > ÃâÃÂ
> > > > > > ÃâÃÂ
> > > > > > ÃâÃÂ
> > > > > > ÃâÃÂ
> > > > > > From: himykabibble <jagboy@>
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > ÃâÃÂ
> > > > > > Brad,
> > > > > >
> > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > your user programs, has that situation improved at all?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Good that your MDI code works though.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > using some [STAThread ] component..
> > > > > > > >
> > > > > > > >
> > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > improves.
> > > > > > > >
> > > > > > > > Here is a nice tidy way to do it::
> > > > > > > >
> > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > {
> > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > {
> > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > }
> > > > > > > > else
> > > > > > > > {
> > > > > > > > action();
> > > > > > > > }
> > > > > > > >
> > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > >
> > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > {
> > > > > > > > //Your existing code inside here
> > > > > > > > }
> > > > > > > > ));
> > > > > > > >
> > > > > > > > Let me know if this helps.
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Hello Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > You should invoke it to your textbox.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > problematic
> > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > My
> > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > But
> > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > locks
> > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > Is
> > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > will
> > > > > > > > > fix mine as well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > it
> > > > > > > > > only
> > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > look
> > > > > > > > > at
> > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > commands as
> > > > > > > > > if
> > > > > > > > > > > they were any other MCode.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > try
> > > > > > > > > > > that and get back to you.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > didn't
> > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > >
> > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > InvokeAction a
> > > > > > > > > > > better way to do it?
> > > > > > > > > > >
> > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > Non-motion
> > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > never
> > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > E-stop
> > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > So
> > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > until I
> > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > on
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > and
> > > > > > > > > I
> > > > > > > > > > > get
> > > > > > > > > > > > the same result.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > crash.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > from
> > > > > > > > > > > the
> > > > > > > > > > > > c# console application.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > dirty
> > > > > > > > > > > test::
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > >
> > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > >
> > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > as
> > > > > > > > > well?
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > shared
> > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > had
> > > > > > > > > some
> > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > thing. I
> > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > changed.
> > > > > > > > > > > printfs
> > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > app,
> > > > > > > > > so
> > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > working,
> > > > > > > > > > > so
> > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > really
> > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > KMotionCNC....
> > > > > > > > > > > >
> > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > fine,
> > > > > > > > > but
> > > > > > > > > > > NOT
> > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > DSP
> > > > > > > > > > > tasks
> > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > the
> > > > > > > > > task
> > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > without
> > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Tom,
> > > > > > > > > > > > >
> > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > >
> > > > > > > > > > > > > main()
> > > > > > > > > > > > > {
> > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > time.
> > > > > > > > > The
> > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > strangely in
> > > > > > > > > any
> > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > But, if
> > > > > > > > > I
> > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > KMotion
> > > > > > > > > > > will
> > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > console,
> > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > until I
> > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > influencing
> > > > > > > > > the
> > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > wouldn't be
> > > > > > > > > > > doing
> > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > more
> > > > > > > > > like a
> > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > it
> > > > > > > > > do
> > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > the
> > > > > > > > > > > KMotion
> > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > TK
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > on
> > > > > > > > > how
> > > > > > > > > > > to
> > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > just
> > > > > > > > > > > fine.
> > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > it
> > > > > > > > > seems
> > > > > > > > > > > to
> > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > code
> > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > that,
> > > > > > > > > > > the
> > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > run
> > > > > > > > > the
> > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > even
> > > > > > > > > > > though
> > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > opens
> > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > no
> > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > having
> > > > > > > > > both
> > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > reluctant
> > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > up
> > > > > > > > > > > 2010,
> > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > build
> > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > not
> > > > > > > > > the
> > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > that
> > > > > > > > > is
> > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > wrong,
> > > > > > > > > > > or
> > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > comment
> > > > > > > > > out
> > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > problem
> > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > that
> > > > > > > > > one
> > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > "signature"
> > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > Persist
> > > > > > > > > > > location
> > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > and
> > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > the
> > > > > > > > > new
> > > > > > > > > > > app
> > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > KM_Controller
> > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > constructors
> > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > wrong
> > > > > > > > > AFTER
> > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > would
> > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > shifted
> > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > location. So
> > > > > > > > > > > it's
> > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > connected
> > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > the
> > > > > > > > > PC
> > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > word. So
> > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > surrounded
> > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > token
> > > > > > > > > > > (the
> > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > are
> > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > running:
> > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > (which
> > > > > > > > > > > is
> > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > rate,
> > > > > > > > > mostly
> > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > "connected"
> > > > > > > > > LED
> > > > > > > > > > > in
> > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > checkboxes.
> > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > methods
> > > > > > > > > > > are
> > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > that
> > > > > > > > > would
> > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3627 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Tom,
Yeah, I can see how to easily do that. I did just put the PCComm handler in a separate worker thread, and it does appear to be working. I'll continue testing it, and see if I can come up with something better, and wait to see what Brad thinks.
You may have just found the thing that's been making my life miserable for at least the last week! Thanks! Even if it's not fixed, now that we know what it is, a solution will be found!
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> No I think more threads would make things worse. I'm curious what Brad thinks. But the only thing I can think of is to make a FIFO of console messages. So the ConsoleCallback can always just push the message someplace and return. Then another thread or one of your existing Threads can later pull the message from the FIFO and display it while it does not have KFLOP locked. BTW if you do take this approach the FIFO must be Thread Safe which probably means a Mutex around it. Otherwise something might happen like one thread is in the process of reading out a string and gets pre-empted, then the other Thread decides to push a string in but there isn't enough space so it re-allocates (moves) the memory or something similar. I think a single Thread handling the GUI would simplify things a lot.Â
> Â
> TK
>
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, January 30, 2012 6:58 PM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Ray, Here is your deadlock situation
> > ÃÂ
> > Main Thread
> > ÃÂ ÃÂ DisplayTimer Tick
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ Service KFLOP Commands
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetPersistVar(100)
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WriteLineReadLine
> > ÃÂ
> > WorkerThread
> > ÃÂ ÃÂ UpdateControls
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetCommandedSpindleRPM()
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetPersistVarAsFloat
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WriteLineReadLine
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ OnKMCallbackÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ OnMessageÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ KMController_ConsoleMessageHandlerÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ConsoleMessageHandlerCallbackÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ UpdateDocument( ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ProgramRunPageForm.Invoke(action);newAction( delegate()
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
> > ÃÂ
> > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > ÃÂ
> > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > ÃÂ
> > TK
> > ÃÂ
> > ÃÂ
> > ÃÂ
> > ÃÂ
> > ÃÂ
> > From: himykabibble <jagboy@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Monday, January 30, 2012 6:31 PM
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> > ÃÂ
> > Tom,
> >
> > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Ray/Brad,
> > > ÃâÃÂ
> > > I don't think starting DSP programs is the issue.
> > > ÃâÃÂ
> > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > ÃâÃÂ
> > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃâàÃâàOne Thread did a WriteLineReadLine which resulted in aÃâàConsole Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > ÃâÃÂ
> > > Maybe Brad can explain his understanding of this Invoke stuff.ÃâàDoes the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > ÃâÃÂ
> > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃâàAny thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > ÃâÃÂ
> > > Regards
> > > TK
> > > ÃâÃÂ
> > >
> > > From: himykabibble <jagboy@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Monday, January 30, 2012 5:51 PM
> > > Subject: [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > > ÃâÃÂ
> > > Brad,
> > >
> > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > >
> > > > Ray,
> > > >
> > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > >
> > > >
> > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > >
> > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > >
> > > > Let me know if that works for you as well.
> > > >
> > > > -Brad Murry
> > > >
> > > >
> > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > >
> > > > > Tom,
> > > > >
> > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > >
> > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > > Hi Ray,
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃÆ'ââ¬Å¡ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃÆ'ââ¬Å¡ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃÆ'ââ¬Å¡ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > Regards
> > > > > > TK
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > From: himykabibble <jagboy@>
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > Brad,
> > > > > >
> > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > your user programs, has that situation improved at all?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Good that your MDI code works though.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > using some [STAThread ] component..
> > > > > > > >
> > > > > > > >
> > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > improves.
> > > > > > > >
> > > > > > > > Here is a nice tidy way to do it::
> > > > > > > >
> > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > {
> > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > {
> > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > }
> > > > > > > > else
> > > > > > > > {
> > > > > > > > action();
> > > > > > > > }
> > > > > > > >
> > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > >
> > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > {
> > > > > > > > //Your existing code inside here
> > > > > > > > }
> > > > > > > > ));
> > > > > > > >
> > > > > > > > Let me know if this helps.
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Hello Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > You should invoke it to your textbox.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > problematic
> > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > My
> > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > But
> > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > locks
> > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > Is
> > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > will
> > > > > > > > > fix mine as well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > it
> > > > > > > > > only
> > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > look
> > > > > > > > > at
> > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > commands as
> > > > > > > > > if
> > > > > > > > > > > they were any other MCode.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > try
> > > > > > > > > > > that and get back to you.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > didn't
> > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > >
> > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > InvokeAction a
> > > > > > > > > > > better way to do it?
> > > > > > > > > > >
> > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > Non-motion
> > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > never
> > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > E-stop
> > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > So
> > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > until I
> > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > on
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > and
> > > > > > > > > I
> > > > > > > > > > > get
> > > > > > > > > > > > the same result.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > crash.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > from
> > > > > > > > > > > the
> > > > > > > > > > > > c# console application.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > dirty
> > > > > > > > > > > test::
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > >
> > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > >
> > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > as
> > > > > > > > > well?
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > shared
> > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > had
> > > > > > > > > some
> > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > thing. I
> > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > changed.
> > > > > > > > > > > printfs
> > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > app,
> > > > > > > > > so
> > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > working,
> > > > > > > > > > > so
> > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > really
> > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > KMotionCNC....
> > > > > > > > > > > >
> > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > fine,
> > > > > > > > > but
> > > > > > > > > > > NOT
> > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > DSP
> > > > > > > > > > > tasks
> > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > the
> > > > > > > > > task
> > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > without
> > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Tom,
> > > > > > > > > > > > >
> > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > >
> > > > > > > > > > > > > main()
> > > > > > > > > > > > > {
> > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > time.
> > > > > > > > > The
> > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > strangely in
> > > > > > > > > any
> > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > But, if
> > > > > > > > > I
> > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > KMotion
> > > > > > > > > > > will
> > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > console,
> > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > until I
> > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > influencing
> > > > > > > > > the
> > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > wouldn't be
> > > > > > > > > > > doing
> > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > more
> > > > > > > > > like a
> > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > it
> > > > > > > > > do
> > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > the
> > > > > > > > > > > KMotion
> > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > TK
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > on
> > > > > > > > > how
> > > > > > > > > > > to
> > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > just
> > > > > > > > > > > fine.
> > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > it
> > > > > > > > > seems
> > > > > > > > > > > to
> > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > code
> > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > that,
> > > > > > > > > > > the
> > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > run
> > > > > > > > > the
> > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > even
> > > > > > > > > > > though
> > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > opens
> > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > no
> > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > having
> > > > > > > > > both
> > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > reluctant
> > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > up
> > > > > > > > > > > 2010,
> > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > build
> > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > not
> > > > > > > > > the
> > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > that
> > > > > > > > > is
> > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > wrong,
> > > > > > > > > > > or
> > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > comment
> > > > > > > > > out
> > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > problem
> > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > that
> > > > > > > > > one
> > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > "signature"
> > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > Persist
> > > > > > > > > > > location
> > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > and
> > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > the
> > > > > > > > > new
> > > > > > > > > > > app
> > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > KM_Controller
> > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > constructors
> > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > wrong
> > > > > > > > > AFTER
> > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > would
> > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > shifted
> > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > location. So
> > > > > > > > > > > it's
> > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > connected
> > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > the
> > > > > > > > > PC
> > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > word. So
> > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > surrounded
> > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > token
> > > > > > > > > > > (the
> > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > are
> > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > running:
> > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > (which
> > > > > > > > > > > is
> > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > rate,
> > > > > > > > > mostly
> > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > "connected"
> > > > > > > > > LED
> > > > > > > > > > > in
> > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > checkboxes.
> > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > methods
> > > > > > > > > > > are
> > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > that
> > > > > > > > > would
> > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3628 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Brad,
Can you tell me which files you modified? They've all been "touched", and I don't have a decent diff tool.
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@...> wrote:
>
> I saw the deadlock as well. You also had timers competing with your worker thread.
>
>
> I got rid of all timers and re-routed the synchronous calls that were competing for the Kflop (and GUI) as Tom pointed out.
>
> I will upload your modified source.
>
> -Brad
>
>
>
> --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> >
> > Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Ray, Here is your deadlock situation
> > > Â
> > > Main Thread
> > > Â Â DisplayTimer Tick
> > > Â Â Â Â Â Service KFLOP Commands
> > > Â Â Â Â Â Â Â Â GetPersistVar(100)
> > > Â Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> > > Â
> > > WorkerThread
> > > Â Â UpdateControls
> > > Â Â Â Â Â GetCommandedSpindleRPM()
> > > Â Â Â Â Â Â GetPersistVarAsFloat
> > > Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> > >             OnKMCallback                OnMessage                  KMController_ConsoleMessageHandler                      ConsoleMessageHandlerCallback                        UpdateDocument(                            ProgramRunPageForm.Invoke(action);newAction( delegate()
> > > Â Â Â Â Â
> > > Â
> > > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > > Â
> > > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > > Â
> > > TK
> > > Â
> > > Â
> > > Â
> > > Â
> > > Â
> > > From: himykabibble <jagboy@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Monday, January 30, 2012 6:31 PM
> > > Subject: [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > > Â
> > > Tom,
> > >
> > > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > >
> > > > Hi Ray/Brad,
> > > > ÃÂ
> > > > I don't think starting DSP programs is the issue.
> > > > ÃÂ
> > > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > > ÃÂ
> > > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃÂ ÃÂ One Thread did a WriteLineReadLine which resulted in aÃÂ Console Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > > ÃÂ
> > > > Maybe Brad can explain his understanding of this Invoke stuff.ÃÂ Does the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > > ÃÂ
> > > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃÂ Any thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > > ÃÂ
> > > > Regards
> > > > TK
> > > > ÃÂ
> > > >
> > > > From: himykabibble <jagboy@>
> > > > To: DynoMotion@yahoogroups.com
> > > > Sent: Monday, January 30, 2012 5:51 PM
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > > ÃÂ
> > > > Brad,
> > > >
> > > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > > >
> > > > > Ray,
> > > > >
> > > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > > >
> > > > >
> > > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > > >
> > > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > > >
> > > > > Let me know if that works for you as well.
> > > > >
> > > > > -Brad Murry
> > > > >
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > > >
> > > > > > Tom,
> > > > > >
> > > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > > >
> > > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > > >
> > > > > > > Hi Ray,
> > > > > > > ÃâÃÂ
> > > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > > ÃâÃÂ
> > > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > > ÃâÃÂ
> > > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > > ÃâÃÂ
> > > > > > > Regards
> > > > > > > TK
> > > > > > > ÃâÃÂ
> > > > > > > ÃâÃÂ
> > > > > > > ÃâÃÂ
> > > > > > > ÃâÃÂ
> > > > > > > From: himykabibble <jagboy@>
> > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > > ÃâÃÂ
> > > > > > > Brad,
> > > > > > >
> > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Ray,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > > your user programs, has that situation improved at all?
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Good that your MDI code works though.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > > using some [STAThread ] component..
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > > improves.
> > > > > > > > >
> > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > >
> > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > {
> > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > {
> > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > }
> > > > > > > > > else
> > > > > > > > > {
> > > > > > > > > action();
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > > >
> > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > {
> > > > > > > > > //Your existing code inside here
> > > > > > > > > }
> > > > > > > > > ));
> > > > > > > > >
> > > > > > > > > Let me know if this helps.
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hello Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > > problematic
> > > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > > My
> > > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > > But
> > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > > locks
> > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > > Is
> > > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > > will
> > > > > > > > > > fix mine as well.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > > it
> > > > > > > > > > only
> > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > > look
> > > > > > > > > > at
> > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > > commands as
> > > > > > > > > > if
> > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > > try
> > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > > didn't
> > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > >
> > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > > InvokeAction a
> > > > > > > > > > > > better way to do it?
> > > > > > > > > > > >
> > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > > Non-motion
> > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > > never
> > > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > > E-stop
> > > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > > So
> > > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > > until I
> > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > > on
> > > > > > > > > > here.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > > and
> > > > > > > > > > I
> > > > > > > > > > > > get
> > > > > > > > > > > > > the same result.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > > crash.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > > from
> > > > > > > > > > > > the
> > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > > dirty
> > > > > > > > > > > > test::
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > >
> > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > >
> > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > >
> > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > > here.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > > as
> > > > > > > > > > well?
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > On
> > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Tom,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > > shared
> > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > > had
> > > > > > > > > > some
> > > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > > thing. I
> > > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > > changed.
> > > > > > > > > > > > printfs
> > > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > > app,
> > > > > > > > > > so
> > > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > > working,
> > > > > > > > > > > > so
> > > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > > really
> > > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > > KMotionCNC....
> > > > > > > > > > > > >
> > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > > fine,
> > > > > > > > > > but
> > > > > > > > > > > > NOT
> > > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > > DSP
> > > > > > > > > > > > tasks
> > > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > > the
> > > > > > > > > > task
> > > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > > without
> > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > {
> > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > }
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > > time.
> > > > > > > > > > The
> > > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > > strangely in
> > > > > > > > > > any
> > > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > > But, if
> > > > > > > > > > I
> > > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > > KMotion
> > > > > > > > > > > > will
> > > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > > console,
> > > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > > until I
> > > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > > influencing
> > > > > > > > > > the
> > > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > > wouldn't be
> > > > > > > > > > > > doing
> > > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > > more
> > > > > > > > > > like a
> > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > > it
> > > > > > > > > > do
> > > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > > the
> > > > > > > > > > > > KMotion
> > > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > > on
> > > > > > > > > > how
> > > > > > > > > > > > to
> > > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > > just
> > > > > > > > > > > > fine.
> > > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > > it
> > > > > > > > > > seems
> > > > > > > > > > > > to
> > > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > > code
> > > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > > that,
> > > > > > > > > > > > the
> > > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > > run
> > > > > > > > > > the
> > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > > even
> > > > > > > > > > > > though
> > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > > opens
> > > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > > no
> > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > > having
> > > > > > > > > > both
> > > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > > reluctant
> > > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > > up
> > > > > > > > > > > > 2010,
> > > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > > build
> > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > > not
> > > > > > > > > > the
> > > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > > that
> > > > > > > > > > is
> > > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > > wrong,
> > > > > > > > > > > > or
> > > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > > comment
> > > > > > > > > > out
> > > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > > problem
> > > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > > that
> > > > > > > > > > one
> > > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > > "signature"
> > > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > > Persist
> > > > > > > > > > > > location
> > > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > > and
> > > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > > the
> > > > > > > > > > new
> > > > > > > > > > > > app
> > > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > > constructors
> > > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > > wrong
> > > > > > > > > > AFTER
> > > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > > would
> > > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > > shifted
> > > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > > location. So
> > > > > > > > > > > > it's
> > > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > > connected
> > > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > > the
> > > > > > > > > > PC
> > > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > > word. So
> > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > > surrounded
> > > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > > token
> > > > > > > > > > > > (the
> > > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > > are
> > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > > running:
> > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > > (which
> > > > > > > > > > > > is
> > > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > > rate,
> > > > > > > > > > mostly
> > > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > > "connected"
> > > > > > > > > > LED
> > > > > > > > > > > > in
> > > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > > methods
> > > > > > > > > > > > are
> > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > > that
> > > > > > > > > > would
> > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3629 |
From: bradodarb |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
More threads do equal more complexity, but I think creating a thread for a unit of work is ok if a) you mange the lifespan of it correctly and b)ensure it will not incur a deadlock and yields properly when not actually performing real work. That is not to say you should just make a bunch of threads for eack thing you need to do, but I could see managing the FIFO (Que<T> in .net) from it's own thread.
Then again I do not think that a FIFO is required, just gather all the data on a background thread and Invoke/BeginInvoke to your GUI.
As an aside, MM uses 1 thread for updating the data that gets pushed to the UI, 1 thread for the actual UI and then extra threads as needed for processing parts. In MM2 at work with a machine that has 3 separate axis groups, multiple work zones, loaders,unloaders, calls to web services for part data, calls to web services for machine logging, etc.... there may be 10-20 threads working at a time. Sure this could be almost done synchronously by splitting tasks up into time sliced units of work, but(IMHO) it is a lot cleaner and more performant to separate tasks into their own units of work, and manage the data and lifespan between them. I think MM2 may occasionally spike at 20% CPU usage on a big machine with 10's of axis but typically idles around 5%.
I am not tooting MY horn here, but rather .net's threading API's that really make it nice(I won't say easy) to create a high performance multi-threaded app. And with .net4 its even better.
-Brad Murry
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> No I think more threads would make things worse. I'm curious what Brad thinks. But the only thing I can think of is to make a FIFO of console messages. So the ConsoleCallback can always just push the message someplace and return. Then another thread or one of your existing Threads can later pull the message from the FIFO and display it while it does not have KFLOP locked. BTW if you do take this approach the FIFO must be Thread Safe which probably means a Mutex around it. Otherwise something might happen like one thread is in the process of reading out a string and gets pre-empted, then the other Thread decides to push a string in but there isn't enough space so it re-allocates (moves) the memory or something similar. I think a single Thread handling the GUI would simplify things a lot.Â
> Â
> TK
>
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, January 30, 2012 6:58 PM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Ray, Here is your deadlock situation
> > ÃÂ
> > Main Thread
> > ÃÂ ÃÂ DisplayTimer Tick
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ Service KFLOP Commands
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetPersistVar(100)
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WriteLineReadLine
> > ÃÂ
> > WorkerThread
> > ÃÂ ÃÂ UpdateControls
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetCommandedSpindleRPM()
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetPersistVarAsFloat
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WriteLineReadLine
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ OnKMCallbackÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ OnMessageÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ KMController_ConsoleMessageHandlerÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ConsoleMessageHandlerCallbackÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ UpdateDocument( ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ProgramRunPageForm.Invoke(action);newAction( delegate()
> > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
> > ÃÂ
> > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > ÃÂ
> > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > ÃÂ
> > TK
> > ÃÂ
> > ÃÂ
> > ÃÂ
> > ÃÂ
> > ÃÂ
> > From: himykabibble <jagboy@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Monday, January 30, 2012 6:31 PM
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> > ÃÂ
> > Tom,
> >
> > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Ray/Brad,
> > > ÃâÃÂ
> > > I don't think starting DSP programs is the issue.
> > > ÃâÃÂ
> > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > ÃâÃÂ
> > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃâàÃâàOne Thread did a WriteLineReadLine which resulted in aÃâàConsole Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > ÃâÃÂ
> > > Maybe Brad can explain his understanding of this Invoke stuff.ÃâàDoes the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > ÃâÃÂ
> > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃâàAny thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > ÃâÃÂ
> > > Regards
> > > TK
> > > ÃâÃÂ
> > >
> > > From: himykabibble <jagboy@>
> > > To: DynoMotion@yahoogroups.com
> > > Sent: Monday, January 30, 2012 5:51 PM
> > > Subject: [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > > ÃâÃÂ
> > > Brad,
> > >
> > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > >
> > > > Ray,
> > > >
> > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > >
> > > >
> > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > >
> > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > >
> > > > Let me know if that works for you as well.
> > > >
> > > > -Brad Murry
> > > >
> > > >
> > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > >
> > > > > Tom,
> > > > >
> > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > >
> > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > > Hi Ray,
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃÆ'ââ¬Å¡ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃÆ'ââ¬Å¡ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃÆ'ââ¬Å¡ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > Regards
> > > > > > TK
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > From: himykabibble <jagboy@>
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > Brad,
> > > > > >
> > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > your user programs, has that situation improved at all?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Good that your MDI code works though.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > using some [STAThread ] component..
> > > > > > > >
> > > > > > > >
> > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > improves.
> > > > > > > >
> > > > > > > > Here is a nice tidy way to do it::
> > > > > > > >
> > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > {
> > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > {
> > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > }
> > > > > > > > else
> > > > > > > > {
> > > > > > > > action();
> > > > > > > > }
> > > > > > > >
> > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > >
> > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > {
> > > > > > > > //Your existing code inside here
> > > > > > > > }
> > > > > > > > ));
> > > > > > > >
> > > > > > > > Let me know if this helps.
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Hello Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > You should invoke it to your textbox.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > problematic
> > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > My
> > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > But
> > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > locks
> > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > Is
> > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > will
> > > > > > > > > fix mine as well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > it
> > > > > > > > > only
> > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > look
> > > > > > > > > at
> > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > commands as
> > > > > > > > > if
> > > > > > > > > > > they were any other MCode.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > try
> > > > > > > > > > > that and get back to you.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > didn't
> > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > >
> > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > InvokeAction a
> > > > > > > > > > > better way to do it?
> > > > > > > > > > >
> > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > Non-motion
> > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > never
> > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > E-stop
> > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > So
> > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > until I
> > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > on
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > and
> > > > > > > > > I
> > > > > > > > > > > get
> > > > > > > > > > > > the same result.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > crash.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > from
> > > > > > > > > > > the
> > > > > > > > > > > > c# console application.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > dirty
> > > > > > > > > > > test::
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > >
> > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > >
> > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > as
> > > > > > > > > well?
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > shared
> > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > had
> > > > > > > > > some
> > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > thing. I
> > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > changed.
> > > > > > > > > > > printfs
> > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > app,
> > > > > > > > > so
> > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > working,
> > > > > > > > > > > so
> > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > really
> > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > KMotionCNC....
> > > > > > > > > > > >
> > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > fine,
> > > > > > > > > but
> > > > > > > > > > > NOT
> > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > DSP
> > > > > > > > > > > tasks
> > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > the
> > > > > > > > > task
> > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > without
> > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Tom,
> > > > > > > > > > > > >
> > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > >
> > > > > > > > > > > > > main()
> > > > > > > > > > > > > {
> > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > time.
> > > > > > > > > The
> > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > strangely in
> > > > > > > > > any
> > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > But, if
> > > > > > > > > I
> > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > KMotion
> > > > > > > > > > > will
> > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > console,
> > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > until I
> > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > influencing
> > > > > > > > > the
> > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > wouldn't be
> > > > > > > > > > > doing
> > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > more
> > > > > > > > > like a
> > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > it
> > > > > > > > > do
> > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > the
> > > > > > > > > > > KMotion
> > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > TK
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > on
> > > > > > > > > how
> > > > > > > > > > > to
> > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > just
> > > > > > > > > > > fine.
> > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > it
> > > > > > > > > seems
> > > > > > > > > > > to
> > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > code
> > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > that,
> > > > > > > > > > > the
> > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > run
> > > > > > > > > the
> > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > even
> > > > > > > > > > > though
> > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > opens
> > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > no
> > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > having
> > > > > > > > > both
> > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > reluctant
> > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > up
> > > > > > > > > > > 2010,
> > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > build
> > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > not
> > > > > > > > > the
> > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > that
> > > > > > > > > is
> > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > wrong,
> > > > > > > > > > > or
> > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > comment
> > > > > > > > > out
> > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > problem
> > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > that
> > > > > > > > > one
> > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > "signature"
> > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > Persist
> > > > > > > > > > > location
> > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > and
> > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > the
> > > > > > > > > new
> > > > > > > > > > > app
> > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > KM_Controller
> > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > constructors
> > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > wrong
> > > > > > > > > AFTER
> > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > would
> > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > shifted
> > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > location. So
> > > > > > > > > > > it's
> > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > connected
> > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > the
> > > > > > > > > PC
> > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > word. So
> > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > surrounded
> > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > token
> > > > > > > > > > > (the
> > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > are
> > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > running:
> > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > (which
> > > > > > > > > > > is
> > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > rate,
> > > > > > > > > mostly
> > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > "connected"
> > > > > > > > > LED
> > > > > > > > > > > in
> > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > checkboxes.
> > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > methods
> > > > > > > > > > > are
> > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > that
> > > > > > > > > would
> > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3630 |
From: bradodarb |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Tom turned me on to WinMerge, its pretty nice to use.
-Brad Murry
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Brad,
>
> Can you tell me which files you modified? They've all been "touched", and I don't have a decent diff tool.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> >
> > I saw the deadlock as well. You also had timers competing with your worker thread.
> >
> >
> > I got rid of all timers and re-routed the synchronous calls that were competing for the Kflop (and GUI) as Tom pointed out.
> >
> > I will upload your modified source.
> >
> > -Brad
> >
> >
> >
> > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > >
> > > Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > >
> > > > Ray, Here is your deadlock situation
> > > > Â
> > > > Main Thread
> > > > Â Â DisplayTimer Tick
> > > > Â Â Â Â Â Service KFLOP Commands
> > > > Â Â Â Â Â Â Â Â GetPersistVar(100)
> > > > Â Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> > > > Â
> > > > WorkerThread
> > > > Â Â UpdateControls
> > > > Â Â Â Â Â GetCommandedSpindleRPM()
> > > > Â Â Â Â Â Â GetPersistVarAsFloat
> > > > Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> > > >             OnKMCallback                OnMessage                  KMController_ConsoleMessageHandler                      ConsoleMessageHandlerCallback                        UpdateDocument(                            ProgramRunPageForm.Invoke(action);newAction( delegate()
> > > > Â Â Â Â Â
> > > > Â
> > > > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > > > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > > > Â
> > > > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > > > Â
> > > > TK
> > > > Â
> > > > Â
> > > > Â
> > > > Â
> > > > Â
> > > > From: himykabibble <jagboy@>
> > > > To: DynoMotion@yahoogroups.com
> > > > Sent: Monday, January 30, 2012 6:31 PM
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > > Â
> > > > Tom,
> > > >
> > > > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > Hi Ray/Brad,
> > > > > ÃÂ
> > > > > I don't think starting DSP programs is the issue.
> > > > > ÃÂ
> > > > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > > > ÃÂ
> > > > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃÂ ÃÂ One Thread did a WriteLineReadLine which resulted in aÃÂ Console Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > > > ÃÂ
> > > > > Maybe Brad can explain his understanding of this Invoke stuff.ÃÂ Does the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > > > ÃÂ
> > > > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃÂ Any thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > > > ÃÂ
> > > > > Regards
> > > > > TK
> > > > > ÃÂ
> > > > >
> > > > > From: himykabibble <jagboy@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Monday, January 30, 2012 5:51 PM
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > ÃÂ
> > > > > Brad,
> > > > >
> > > > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > > > >
> > > > > > Ray,
> > > > > >
> > > > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > > > >
> > > > > >
> > > > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > > > >
> > > > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > > > >
> > > > > > Let me know if that works for you as well.
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > > > >
> > > > > > > Tom,
> > > > > > >
> > > > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > > > >
> > > > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > > > >
> > > > > > > > Hi Ray,
> > > > > > > > ÃâÃÂ
> > > > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > > > ÃâÃÂ
> > > > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > > > ÃâÃÂ
> > > > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > > > ÃâÃÂ
> > > > > > > > Regards
> > > > > > > > TK
> > > > > > > > ÃâÃÂ
> > > > > > > > ÃâÃÂ
> > > > > > > > ÃâÃÂ
> > > > > > > > ÃâÃÂ
> > > > > > > > From: himykabibble <jagboy@>
> > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > > ÃâÃÂ
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > > > your user programs, has that situation improved at all?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Good that your MDI code works though.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > > > using some [STAThread ] component..
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > > > improves.
> > > > > > > > > >
> > > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > > >
> > > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > > {
> > > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > > {
> > > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > > }
> > > > > > > > > > else
> > > > > > > > > > {
> > > > > > > > > > action();
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > > > >
> > > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > > {
> > > > > > > > > > //Your existing code inside here
> > > > > > > > > > }
> > > > > > > > > > ));
> > > > > > > > > >
> > > > > > > > > > Let me know if this helps.
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hello Ray,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > > > problematic
> > > > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > > > My
> > > > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > > > But
> > > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > > > locks
> > > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > > > Is
> > > > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > > > will
> > > > > > > > > > > fix mine as well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > > > it
> > > > > > > > > > > only
> > > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > > > look
> > > > > > > > > > > at
> > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > > > commands as
> > > > > > > > > > > if
> > > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > > > try
> > > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > -Brad
> > > > > > > > > > > > >
> > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > > > didn't
> > > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > > >
> > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > > > InvokeAction a
> > > > > > > > > > > > > better way to do it?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > > > Non-motion
> > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > > > never
> > > > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > > > E-stop
> > > > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > > > So
> > > > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > > > until I
> > > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > > > on
> > > > > > > > > > > here.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > > > and
> > > > > > > > > > > I
> > > > > > > > > > > > > get
> > > > > > > > > > > > > > the same result.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > > > crash.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > > > from
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > > > dirty
> > > > > > > > > > > > > test::
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > > > here.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > > > as
> > > > > > > > > > > well?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > On
> > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > > > shared
> > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > > > had
> > > > > > > > > > > some
> > > > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > > > thing. I
> > > > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > > > changed.
> > > > > > > > > > > > > printfs
> > > > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > > > app,
> > > > > > > > > > > so
> > > > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > > > working,
> > > > > > > > > > > > > so
> > > > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > > > really
> > > > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > > > KMotionCNC....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > > > fine,
> > > > > > > > > > > but
> > > > > > > > > > > > > NOT
> > > > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > > > DSP
> > > > > > > > > > > > > tasks
> > > > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > > > the
> > > > > > > > > > > task
> > > > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > > > without
> > > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > > > time.
> > > > > > > > > > > The
> > > > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > > > strangely in
> > > > > > > > > > > any
> > > > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > > > But, if
> > > > > > > > > > > I
> > > > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > > > KMotion
> > > > > > > > > > > > > will
> > > > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > > > console,
> > > > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > > > until I
> > > > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > > > influencing
> > > > > > > > > > > the
> > > > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > > > wouldn't be
> > > > > > > > > > > > > doing
> > > > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > > > more
> > > > > > > > > > > like a
> > > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > > > it
> > > > > > > > > > > do
> > > > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > > > the
> > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > > > on
> > > > > > > > > > > how
> > > > > > > > > > > > > to
> > > > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > > > just
> > > > > > > > > > > > > fine.
> > > > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > > > it
> > > > > > > > > > > seems
> > > > > > > > > > > > > to
> > > > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > > > code
> > > > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > > > that,
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > > > run
> > > > > > > > > > > the
> > > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > > > even
> > > > > > > > > > > > > though
> > > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > > > opens
> > > > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > > > no
> > > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > > > having
> > > > > > > > > > > both
> > > > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > > > reluctant
> > > > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > > > up
> > > > > > > > > > > > > 2010,
> > > > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > > > build
> > > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > > > not
> > > > > > > > > > > the
> > > > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > > > that
> > > > > > > > > > > is
> > > > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > > > wrong,
> > > > > > > > > > > > > or
> > > > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > > > comment
> > > > > > > > > > > out
> > > > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > > > problem
> > > > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > > > that
> > > > > > > > > > > one
> > > > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > > > "signature"
> > > > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > > > Persist
> > > > > > > > > > > > > location
> > > > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > > > and
> > > > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > > > the
> > > > > > > > > > > new
> > > > > > > > > > > > > app
> > > > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > > > constructors
> > > > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > > > wrong
> > > > > > > > > > > AFTER
> > > > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > > > would
> > > > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > > > shifted
> > > > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > > > location. So
> > > > > > > > > > > > > it's
> > > > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > > > connected
> > > > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > > > the
> > > > > > > > > > > PC
> > > > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > > > word. So
> > > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > > > surrounded
> > > > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > > > token
> > > > > > > > > > > > > (the
> > > > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > > > are
> > > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > > > running:
> > > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > > > (which
> > > > > > > > > > > > > is
> > > > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > > > rate,
> > > > > > > > > > > mostly
> > > > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > > > "connected"
> > > > > > > > > > > LED
> > > > > > > > > > > > > in
> > > > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > > > methods
> > > > > > > > > > > > > are
> > > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > > > that
> > > > > > > > > > > would
> > > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3631 |
From: Tom Kerekes |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Ray,
BTW Winmerge.org is a simple free tool that I coun't live without.
TK
Group: DynoMotion |
Message: 3632 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Brad,
I've got that. I forgot it will do directories, won't it. I've merged in your changes in ProgramRunPage, KMotionIF, AxisDROUpdateWorker, and it all seems to be working nicely. I am a little confused about one of the changes. I had the Timer handler doing some minor display updates. You're now invoking that from the AxisDROUpdateWorker. Why does that make a difference? My assumption was running it on a Timer was "safe". Doesn't it end up running on the GUI thread just the same?
I've also pushed the PCComm handler to a worker thread, and it seems to be working fine. Do you see a problem with that? Should I just put it on the AxisDRO thread? Do I still need to do something different with the console handler?
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@...> wrote:
>
> Tom turned me on to WinMerge, its pretty nice to use.
>
> -Brad Murry
>
> --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> >
> > Brad,
> >
> > Can you tell me which files you modified? They've all been "touched", and I don't have a decent diff tool.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > >
> > > I saw the deadlock as well. You also had timers competing with your worker thread.
> > >
> > >
> > > I got rid of all timers and re-routed the synchronous calls that were competing for the Kflop (and GUI) as Tom pointed out.
> > >
> > > I will upload your modified source.
> > >
> > > -Brad
> > >
> > >
> > >
> > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > >
> > > > Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > Ray, Here is your deadlock situation
> > > > > Â
> > > > > Main Thread
> > > > > Â Â DisplayTimer Tick
> > > > > Â Â Â Â Â Service KFLOP Commands
> > > > > Â Â Â Â Â Â Â Â GetPersistVar(100)
> > > > > Â Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> > > > > Â
> > > > > WorkerThread
> > > > > Â Â UpdateControls
> > > > > Â Â Â Â Â GetCommandedSpindleRPM()
> > > > > Â Â Â Â Â Â GetPersistVarAsFloat
> > > > > Â Â Â Â Â Â Â Â Â Â WriteLineReadLine
> > > > >             OnKMCallback                OnMessage                  KMController_ConsoleMessageHandler                      ConsoleMessageHandlerCallback                        UpdateDocument(                            ProgramRunPageForm.Invoke(action);newAction( delegate()
> > > > > Â Â Â Â Â
> > > > > Â
> > > > > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > > > > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > > > > Â
> > > > > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > > > > Â
> > > > > TK
> > > > > Â
> > > > > Â
> > > > > Â
> > > > > Â
> > > > > Â
> > > > > From: himykabibble <jagboy@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Monday, January 30, 2012 6:31 PM
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > Â
> > > > > Tom,
> > > > >
> > > > > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > > Hi Ray/Brad,
> > > > > > ÃÂ
> > > > > > I don't think starting DSP programs is the issue.
> > > > > > ÃÂ
> > > > > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > > > > ÃÂ
> > > > > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃÂ ÃÂ One Thread did a WriteLineReadLine which resulted in aÃÂ Console Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > > > > ÃÂ
> > > > > > Maybe Brad can explain his understanding of this Invoke stuff.ÃÂ Does the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > > > > ÃÂ
> > > > > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃÂ Any thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > > > > ÃÂ
> > > > > > Regards
> > > > > > TK
> > > > > > ÃÂ
> > > > > >
> > > > > > From: himykabibble <jagboy@>
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Sent: Monday, January 30, 2012 5:51 PM
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > ÃÂ
> > > > > > Brad,
> > > > > >
> > > > > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > > > > >
> > > > > > >
> > > > > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > > > > >
> > > > > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > > > > >
> > > > > > > Let me know if that works for you as well.
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Tom,
> > > > > > > >
> > > > > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > > > > >
> > > > > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > > > > >
> > > > > > > > > Hi Ray,
> > > > > > > > > ÃâÃÂ
> > > > > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > > > > ÃâÃÂ
> > > > > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > > > > ÃâÃÂ
> > > > > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > > > > ÃâÃÂ
> > > > > > > > > Regards
> > > > > > > > > TK
> > > > > > > > > ÃâÃÂ
> > > > > > > > > ÃâÃÂ
> > > > > > > > > ÃâÃÂ
> > > > > > > > > ÃâÃÂ
> > > > > > > > > From: himykabibble <jagboy@>
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > ÃâÃÂ
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > > > > your user programs, has that situation improved at all?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Good that your MDI code works though.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > > > > using some [STAThread ] component..
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > > > > improves.
> > > > > > > > > > >
> > > > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > > > >
> > > > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > > > {
> > > > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > > > {
> > > > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > > > }
> > > > > > > > > > > else
> > > > > > > > > > > {
> > > > > > > > > > > action();
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > > > > >
> > > > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > > > {
> > > > > > > > > > > //Your existing code inside here
> > > > > > > > > > > }
> > > > > > > > > > > ));
> > > > > > > > > > >
> > > > > > > > > > > Let me know if this helps.
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > > > > problematic
> > > > > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > > > > My
> > > > > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > > > > But
> > > > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > > > > locks
> > > > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > > > > Is
> > > > > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > > > > will
> > > > > > > > > > > > fix mine as well.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > ,
> > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > > > > it
> > > > > > > > > > > > only
> > > > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > > > > look
> > > > > > > > > > > > at
> > > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > > > > commands as
> > > > > > > > > > > > if
> > > > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > > > > try
> > > > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > -Brad
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > On
> > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > > > > didn't
> > > > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > > > > InvokeAction a
> > > > > > > > > > > > > > better way to do it?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > > > > Non-motion
> > > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > > > > never
> > > > > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > > > > E-stop
> > > > > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > > > > So
> > > > > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > > > > until I
> > > > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > > > > on
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > > > > and
> > > > > > > > > > > > I
> > > > > > > > > > > > > > get
> > > > > > > > > > > > > > > the same result.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > > > > crash.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > > > > from
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > > > > dirty
> > > > > > > > > > > > > > test::
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > > > > as
> > > > > > > > > > > > well?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > > On
> > > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > > > > shared
> > > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > > > > had
> > > > > > > > > > > > some
> > > > > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > > > > thing. I
> > > > > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > > > > changed.
> > > > > > > > > > > > > > printfs
> > > > > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > > > > app,
> > > > > > > > > > > > so
> > > > > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > > > > working,
> > > > > > > > > > > > > > so
> > > > > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > > > > really
> > > > > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > > > > KMotionCNC....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > > > > fine,
> > > > > > > > > > > > but
> > > > > > > > > > > > > > NOT
> > > > > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > > > > DSP
> > > > > > > > > > > > > > tasks
> > > > > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > > > > the
> > > > > > > > > > > > task
> > > > > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > > > > without
> > > > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > > > > time.
> > > > > > > > > > > > The
> > > > > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > > > > strangely in
> > > > > > > > > > > > any
> > > > > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > > > > But, if
> > > > > > > > > > > > I
> > > > > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > > > > console,
> > > > > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > > > > until I
> > > > > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > > > > influencing
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > > > > wouldn't be
> > > > > > > > > > > > > > doing
> > > > > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > > > > more
> > > > > > > > > > > > like a
> > > > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > > > > it
> > > > > > > > > > > > do
> > > > > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > > > > the
> > > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > > > > on
> > > > > > > > > > > > how
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > > > > just
> > > > > > > > > > > > > > fine.
> > > > > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > > > > it
> > > > > > > > > > > > seems
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > > > > code
> > > > > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > > > > that,
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > > > > run
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > > > > even
> > > > > > > > > > > > > > though
> > > > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > > > > opens
> > > > > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > > > > no
> > > > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > > > > having
> > > > > > > > > > > > both
> > > > > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > > > > reluctant
> > > > > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > > > > up
> > > > > > > > > > > > > > 2010,
> > > > > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > > > > build
> > > > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > > > > not
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > > > > that
> > > > > > > > > > > > is
> > > > > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > > > > wrong,
> > > > > > > > > > > > > > or
> > > > > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > > > > comment
> > > > > > > > > > > > out
> > > > > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > > > > problem
> > > > > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > > > > that
> > > > > > > > > > > > one
> > > > > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > > > > "signature"
> > > > > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > > > > Persist
> > > > > > > > > > > > > > location
> > > > > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > > > > and
> > > > > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > > > > the
> > > > > > > > > > > > new
> > > > > > > > > > > > > > app
> > > > > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > > > > constructors
> > > > > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > > > > wrong
> > > > > > > > > > > > AFTER
> > > > > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > > > > would
> > > > > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > > > > shifted
> > > > > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > > > > location. So
> > > > > > > > > > > > > > it's
> > > > > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > > > > connected
> > > > > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > > > > the
> > > > > > > > > > > > PC
> > > > > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > > > > word. So
> > > > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > > > > surrounded
> > > > > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > > > > token
> > > > > > > > > > > > > > (the
> > > > > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > > > > are
> > > > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > > > > running:
> > > > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > > > > (which
> > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > > > > rate,
> > > > > > > > > > > > mostly
> > > > > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > > > > "connected"
> > > > > > > > > > > > LED
> > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > > > > methods
> > > > > > > > > > > > > > are
> > > > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > > > > that
> > > > > > > > > > > > would
> > > > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3633 |
From: himykabibble |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Tom/Brad,
Thank you both very much for getting to the bottom of this. I was about to throw in the towel, but it looks like it's all working now, and just in the nick of time, as I was about out of time to work on it. I'll give it's first real run on the machine tomorrow!
It appears VS2008 has some important capabilities 2010Express does not. Perhaps it's time for me to move over.
Brad,
In looking at my code, you likely wondered "What the heck is that idiot doing re-creating all those DROs and buttons?". I imagine if you noticed it, you must think I'm a total frickin' moron. But, one annoying limitation of VS2010 is it does not allow you to create custom controls that you can put into the form designer. So my kludgey work-around was to use existing controls as placeholders, then subclass mine from those, and replace them at run time. Ugly, to be sure, but it works, and it saved time. One thing I WILL do real soon now is create the real controls in VS2008, and import them, then all that kludge code goes away.
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Ray,
> Â
> BTW Winmerge.org is a simple free tool that I coun't live without.
> Â
> TK
>
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, January 30, 2012 7:30 PM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Brad,
>
> Can you tell me which files you modified? They've all been "touched", and I don't have a decent diff tool.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> >
> > I saw the deadlock as well. You also had timers competing with your worker thread.
> >
> >
> > I got rid of all timers and re-routed the synchronous calls that were competing for the Kflop (and GUI) as Tom pointed out.
> >
> > I will upload your modified source.
> >
> > -Brad
> >
> >
> >
> > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > >
> > > Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > >
> > > > Ray, Here is your deadlock situation
> > > > ÃÂ
> > > > Main Thread
> > > > ÃÂ ÃÂ DisplayTimer Tick
> > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ Service KFLOP Commands
> > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetPersistVar(100)
> > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WriteLineReadLine
> > > > ÃÂ
> > > > WorkerThread
> > > > ÃÂ ÃÂ UpdateControls
> > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetCommandedSpindleRPM()
> > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetPersistVarAsFloat
> > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WriteLineReadLine
> > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ OnKMCallbackÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ OnMessageÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ KMController_ConsoleMessageHandlerÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ConsoleMessageHandlerCallbackÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ UpdateDocument( ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ProgramRunPageForm.Invoke(action);newAction( delegate()
> > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
> > > > ÃÂ
> > > > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > > > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > > > ÃÂ
> > > > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > > > ÃÂ
> > > > TK
> > > > ÃÂ
> > > > ÃÂ
> > > > ÃÂ
> > > > ÃÂ
> > > > ÃÂ
> > > > From: himykabibble <jagboy@>
> > > > To: DynoMotion@yahoogroups.com
> > > > Sent: Monday, January 30, 2012 6:31 PM
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > > ÃÂ
> > > > Tom,
> > > >
> > > > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > Hi Ray/Brad,
> > > > > ÃâÃÂ
> > > > > I don't think starting DSP programs is the issue.
> > > > > ÃâÃÂ
> > > > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > > > ÃâÃÂ
> > > > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃâàÃâàOne Thread did a WriteLineReadLine which resulted in aÃâàConsole Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > > > ÃâÃÂ
> > > > > Maybe Brad can explain his understanding of this Invoke stuff.ÃâàDoes the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > > > ÃâÃÂ
> > > > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃâàAny thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > > > ÃâÃÂ
> > > > > Regards
> > > > > TK
> > > > > ÃâÃÂ
> > > > >
> > > > > From: himykabibble <jagboy@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Monday, January 30, 2012 5:51 PM
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > ÃâÃÂ
> > > > > Brad,
> > > > >
> > > > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > > > >
> > > > > > Ray,
> > > > > >
> > > > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > > > >
> > > > > >
> > > > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > > > >
> > > > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > > > >
> > > > > > Let me know if that works for you as well.
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > > > >
> > > > > > > Tom,
> > > > > > >
> > > > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > > > >
> > > > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > > > >
> > > > > > > > Hi Ray,
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃÆ'ââ¬Å¡ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃÆ'ââ¬Å¡ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃÆ'ââ¬Å¡ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > Regards
> > > > > > > > TK
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > From: himykabibble <jagboy@>
> > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > > > your user programs, has that situation improved at all?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Good that your MDI code works though.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > > > using some [STAThread ] component..
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > > > improves.
> > > > > > > > > >
> > > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > > >
> > > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > > {
> > > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > > {
> > > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > > }
> > > > > > > > > > else
> > > > > > > > > > {
> > > > > > > > > > action();
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > > > >
> > > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > > {
> > > > > > > > > > //Your existing code inside here
> > > > > > > > > > }
> > > > > > > > > > ));
> > > > > > > > > >
> > > > > > > > > > Let me know if this helps.
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hello Ray,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > > > problematic
> > > > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > > > My
> > > > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > > > But
> > > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > > > locks
> > > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > > > Is
> > > > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > > > will
> > > > > > > > > > > fix mine as well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > > > it
> > > > > > > > > > > only
> > > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > > > look
> > > > > > > > > > > at
> > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > > > commands as
> > > > > > > > > > > if
> > > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > > > try
> > > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > -Brad
> > > > > > > > > > > > >
> > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > > > didn't
> > > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > > >
> > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > > > InvokeAction a
> > > > > > > > > > > > > better way to do it?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > > > Non-motion
> > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > > > never
> > > > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > > > E-stop
> > > > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > > > So
> > > > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > > > until I
> > > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > > > on
> > > > > > > > > > > here.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > > > and
> > > > > > > > > > > I
> > > > > > > > > > > > > get
> > > > > > > > > > > > > > the same result.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > > > crash.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > > > from
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > > > dirty
> > > > > > > > > > > > > test::
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > > > here.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > > > as
> > > > > > > > > > > well?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > On
> > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > > > shared
> > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > > > had
> > > > > > > > > > > some
> > > > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > > > thing. I
> > > > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > > > changed.
> > > > > > > > > > > > > printfs
> > > > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > > > app,
> > > > > > > > > > > so
> > > > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > > > working,
> > > > > > > > > > > > > so
> > > > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > > > really
> > > > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > > > KMotionCNC....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > > > fine,
> > > > > > > > > > > but
> > > > > > > > > > > > > NOT
> > > > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > > > DSP
> > > > > > > > > > > > > tasks
> > > > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > > > the
> > > > > > > > > > > task
> > > > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > > > without
> > > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > > > time.
> > > > > > > > > > > The
> > > > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > > > strangely in
> > > > > > > > > > > any
> > > > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > > > But, if
> > > > > > > > > > > I
> > > > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > > > KMotion
> > > > > > > > > > > > > will
> > > > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > > > console,
> > > > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > > > until I
> > > > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > > > influencing
> > > > > > > > > > > the
> > > > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > > > wouldn't be
> > > > > > > > > > > > > doing
> > > > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > > > more
> > > > > > > > > > > like a
> > > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > > > it
> > > > > > > > > > > do
> > > > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > > > the
> > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > > > on
> > > > > > > > > > > how
> > > > > > > > > > > > > to
> > > > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > > > just
> > > > > > > > > > > > > fine.
> > > > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > > > it
> > > > > > > > > > > seems
> > > > > > > > > > > > > to
> > > > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > > > code
> > > > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > > > that,
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > > > run
> > > > > > > > > > > the
> > > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > > > even
> > > > > > > > > > > > > though
> > > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > > > opens
> > > > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > > > no
> > > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > > > having
> > > > > > > > > > > both
> > > > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > > > reluctant
> > > > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > > > up
> > > > > > > > > > > > > 2010,
> > > > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > > > build
> > > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > > > not
> > > > > > > > > > > the
> > > > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > > > that
> > > > > > > > > > > is
> > > > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > > > wrong,
> > > > > > > > > > > > > or
> > > > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > > > comment
> > > > > > > > > > > out
> > > > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > > > problem
> > > > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > > > that
> > > > > > > > > > > one
> > > > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > > > "signature"
> > > > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > > > Persist
> > > > > > > > > > > > > location
> > > > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > > > and
> > > > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > > > the
> > > > > > > > > > > new
> > > > > > > > > > > > > app
> > > > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > > > constructors
> > > > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > > > wrong
> > > > > > > > > > > AFTER
> > > > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > > > would
> > > > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > > > shifted
> > > > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > > > location. So
> > > > > > > > > > > > > it's
> > > > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > > > connected
> > > > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > > > the
> > > > > > > > > > > PC
> > > > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > > > word. So
> > > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > > > surrounded
> > > > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > > > token
> > > > > > > > > > > > > (the
> > > > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > > > are
> > > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > > > running:
> > > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > > > (which
> > > > > > > > > > > > > is
> > > > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > > > rate,
> > > > > > > > > > > mostly
> > > > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > > > "connected"
> > > > > > > > > > > LED
> > > > > > > > > > > > > in
> > > > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > > > methods
> > > > > > > > > > > > > are
> > > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > > > that
> > > > > > > > > > > would
> > > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3634 |
From: bradodarb |
Date: 1/30/2012 |
Subject: Re: Need Some Ideas.... |
Hello Ray,
VS2010 has some goodies that were meant to make the designer experience more realistic and reflect more of what you can expect at run-time.
Alas, this can make things screwy if you do not follow the rules(beware that there are some similar caveats inWPF as well)
There are some workarounds, like this one:
http://stackoverflow.com/questions/5405986/vs2010-how-to-avoid-windows-forms-designer-problems-when-working-with-inherited
But then you have to ask yourself is it worth going through all the trouble just to complete the task at hand? If you are making components that you and/or a team will use across several projects or if you are making components to share/sell.... sure. If however you are making your own apps then probably not.
It looks like you have some nice features in your CNC app and I look forward to hearing how it cuts parts.
-Brad Murry
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Tom/Brad,
>
> Thank you both very much for getting to the bottom of this. I was about to throw in the towel, but it looks like it's all working now, and just in the nick of time, as I was about out of time to work on it. I'll give it's first real run on the machine tomorrow!
>
> It appears VS2008 has some important capabilities 2010Express does not. Perhaps it's time for me to move over.
>
> Brad,
>
> In looking at my code, you likely wondered "What the heck is that idiot doing re-creating all those DROs and buttons?". I imagine if you noticed it, you must think I'm a total frickin' moron. But, one annoying limitation of VS2010 is it does not allow you to create custom controls that you can put into the form designer. So my kludgey work-around was to use existing controls as placeholders, then subclass mine from those, and replace them at run time. Ugly, to be sure, but it works, and it saved time. One thing I WILL do real soon now is create the real controls in VS2008, and import them, then all that kludge code goes away.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Ray,
> > Â
> > BTW Winmerge.org is a simple free tool that I coun't live without.
> > Â
> > TK
> >
> > From: himykabibble <jagboy@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Monday, January 30, 2012 7:30 PM
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> > Â
> > Brad,
> >
> > Can you tell me which files you modified? They've all been "touched", and I don't have a decent diff tool.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > >
> > > I saw the deadlock as well. You also had timers competing with your worker thread.
> > >
> > >
> > > I got rid of all timers and re-routed the synchronous calls that were competing for the Kflop (and GUI) as Tom pointed out.
> > >
> > > I will upload your modified source.
> > >
> > > -Brad
> > >
> > >
> > >
> > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > >
> > > > Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > Ray, Here is your deadlock situation
> > > > > ÃÂ
> > > > > Main Thread
> > > > > ÃÂ ÃÂ DisplayTimer Tick
> > > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ Service KFLOP Commands
> > > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetPersistVar(100)
> > > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WriteLineReadLine
> > > > > ÃÂ
> > > > > WorkerThread
> > > > > ÃÂ ÃÂ UpdateControls
> > > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetCommandedSpindleRPM()
> > > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ GetPersistVarAsFloat
> > > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ WriteLineReadLine
> > > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ OnKMCallbackÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ OnMessageÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ KMController_ConsoleMessageHandlerÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ConsoleMessageHandlerCallbackÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ UpdateDocument( ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ProgramRunPageForm.Invoke(action);newAction( delegate()
> > > > > ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
> > > > > ÃÂ
> > > > > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > > > > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > > > > ÃÂ
> > > > > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > > > > ÃÂ
> > > > > TK
> > > > > ÃÂ
> > > > > ÃÂ
> > > > > ÃÂ
> > > > > ÃÂ
> > > > > ÃÂ
> > > > > From: himykabibble <jagboy@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Monday, January 30, 2012 6:31 PM
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > ÃÂ
> > > > > Tom,
> > > > >
> > > > > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > > Hi Ray/Brad,
> > > > > > ÃâÃÂ
> > > > > > I don't think starting DSP programs is the issue.
> > > > > > ÃâÃÂ
> > > > > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > > > > ÃâÃÂ
> > > > > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃâàÃâàOne Thread did a WriteLineReadLine which resulted in aÃâàConsole Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > > > > ÃâÃÂ
> > > > > > Maybe Brad can explain his understanding of this Invoke stuff.ÃâàDoes the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > > > > ÃâÃÂ
> > > > > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃâàAny thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > > > > ÃâÃÂ
> > > > > > Regards
> > > > > > TK
> > > > > > ÃâÃÂ
> > > > > >
> > > > > > From: himykabibble <jagboy@>
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Sent: Monday, January 30, 2012 5:51 PM
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > ÃâÃÂ
> > > > > > Brad,
> > > > > >
> > > > > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > > > > >
> > > > > > >
> > > > > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > > > > >
> > > > > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > > > > >
> > > > > > > Let me know if that works for you as well.
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Tom,
> > > > > > > >
> > > > > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > > > > >
> > > > > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > > > > >
> > > > > > > > > Hi Ray,
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃÆ'ââ¬Å¡ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃÆ'ââ¬Å¡ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃÆ'ââ¬Å¡ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > Regards
> > > > > > > > > TK
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > From: himykabibble <jagboy@>
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > > > > your user programs, has that situation improved at all?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Good that your MDI code works though.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > > > > using some [STAThread ] component..
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > > > > improves.
> > > > > > > > > > >
> > > > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > > > >
> > > > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > > > {
> > > > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > > > {
> > > > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > > > }
> > > > > > > > > > > else
> > > > > > > > > > > {
> > > > > > > > > > > action();
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > > > > >
> > > > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > > > {
> > > > > > > > > > > //Your existing code inside here
> > > > > > > > > > > }
> > > > > > > > > > > ));
> > > > > > > > > > >
> > > > > > > > > > > Let me know if this helps.
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > > > > problematic
> > > > > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > > > > My
> > > > > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > > > > But
> > > > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > > > > locks
> > > > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > > > > Is
> > > > > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > > > > will
> > > > > > > > > > > > fix mine as well.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > ,
> > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > > > > it
> > > > > > > > > > > > only
> > > > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > > > > look
> > > > > > > > > > > > at
> > > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > > > > commands as
> > > > > > > > > > > > if
> > > > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > > > > try
> > > > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > -Brad
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > On
> > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > > > > didn't
> > > > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > > > > InvokeAction a
> > > > > > > > > > > > > > better way to do it?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > > > > Non-motion
> > > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > > > > never
> > > > > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > > > > E-stop
> > > > > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > > > > So
> > > > > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > > > > until I
> > > > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > > > > on
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > > > > and
> > > > > > > > > > > > I
> > > > > > > > > > > > > > get
> > > > > > > > > > > > > > > the same result.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > > > > crash.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > > > > from
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > > > > dirty
> > > > > > > > > > > > > > test::
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > > > > as
> > > > > > > > > > > > well?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > > On
> > > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > > > > shared
> > > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > > > > had
> > > > > > > > > > > > some
> > > > > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > > > > thing. I
> > > > > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > > > > changed.
> > > > > > > > > > > > > > printfs
> > > > > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > > > > app,
> > > > > > > > > > > > so
> > > > > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > > > > working,
> > > > > > > > > > > > > > so
> > > > > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > > > > really
> > > > > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > > > > KMotionCNC....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > > > > fine,
> > > > > > > > > > > > but
> > > > > > > > > > > > > > NOT
> > > > > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > > > > DSP
> > > > > > > > > > > > > > tasks
> > > > > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > > > > the
> > > > > > > > > > > > task
> > > > > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > > > > without
> > > > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > > > > time.
> > > > > > > > > > > > The
> > > > > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > > > > strangely in
> > > > > > > > > > > > any
> > > > > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > > > > But, if
> > > > > > > > > > > > I
> > > > > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > > > > console,
> > > > > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > > > > until I
> > > > > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > > > > influencing
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > > > > wouldn't be
> > > > > > > > > > > > > > doing
> > > > > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > > > > more
> > > > > > > > > > > > like a
> > > > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > > > > it
> > > > > > > > > > > > do
> > > > > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > > > > the
> > > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > > > > on
> > > > > > > > > > > > how
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > > > > just
> > > > > > > > > > > > > > fine.
> > > > > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > > > > it
> > > > > > > > > > > > seems
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > > > > code
> > > > > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > > > > that,
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > > > > run
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > > > > even
> > > > > > > > > > > > > > though
> > > > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > > > > opens
> > > > > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > > > > no
> > > > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > > > > having
> > > > > > > > > > > > both
> > > > > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > > > > reluctant
> > > > > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > > > > up
> > > > > > > > > > > > > > 2010,
> > > > > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > > > > build
> > > > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > > > > not
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > > > > that
> > > > > > > > > > > > is
> > > > > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > > > > wrong,
> > > > > > > > > > > > > > or
> > > > > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > > > > comment
> > > > > > > > > > > > out
> > > > > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > > > > problem
> > > > > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > > > > that
> > > > > > > > > > > > one
> > > > > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > > > > "signature"
> > > > > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > > > > Persist
> > > > > > > > > > > > > > location
> > > > > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > > > > and
> > > > > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > > > > the
> > > > > > > > > > > > new
> > > > > > > > > > > > > > app
> > > > > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > > > > constructors
> > > > > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > > > > wrong
> > > > > > > > > > > > AFTER
> > > > > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > > > > would
> > > > > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > > > > shifted
> > > > > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > > > > location. So
> > > > > > > > > > > > > > it's
> > > > > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > > > > connected
> > > > > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > > > > the
> > > > > > > > > > > > PC
> > > > > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > > > > word. So
> > > > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > > > > surrounded
> > > > > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > > > > token
> > > > > > > > > > > > > > (the
> > > > > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > > > > are
> > > > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > > > > running:
> > > > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > > > > (which
> > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > > > > rate,
> > > > > > > > > > > > mostly
> > > > > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > > > > "connected"
> > > > > > > > > > > > LED
> > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > > > > methods
> > > > > > > > > > > > > > are
> > > > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > > > > that
> > > > > > > > > > > > would
> > > > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3636 |
From: Tom Kerekes |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Hi Ray,
BTW one think I've been meaning to mention was that I saw a few places where you were using ReadLineTimeout with a timout of 500ms. I think this will work 99.99% of the time, but by luck if Windows ever "freezes" for more than 500ms at just the wrong time the ReadLine won't finish and things will all get out of sync and probably result in a disconnect. I think Windows freezes of ~ 500ms are fairly common on some systems. Either set the timeout to a huge value (like 10 seconds) or just use ReadLine without the timeout. The call should always return in a reasonable time. If there is a disconnect or something that prevents the read the call will return immediately with an error.
Regards
TK
Group: DynoMotion |
Message: 3637 |
From: himykabibble |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Tom,
OK, I'll change that. I saw whatever code I copied that from and thought 5000 was an unreasonable value, but now it makes sense.
Thanks!
I'm trying right now to get the app moved over to the PC on my machine. Lots to install....
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Ray,
> Â
> BTW one think I've been meaning to mention was that I saw a few places where you were using ReadLineTimeout with a timout of 500ms. I think this will work 99.99% of the time, but by luck if Windows ever "freezes" for more than 500ms at just the wrong time the ReadLine won't finish and things will all get out of sync and probably result in a disconnect. I think Windows freezes of ~ 500ms are fairly common on some systems. Either set the timeout to a huge value (like 10 seconds) or just use ReadLine without the timeout. The call should always return in a reasonable time. If there is a disconnect or something that prevents the read the call will return immediately with an error.
> Â
> Regards
> TK
>
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Monday, January 30, 2012 8:15 PM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Tom/Brad,
>
> Thank you both very much for getting to the bottom of this. I was about to throw in the towel, but it looks like it's all working now, and just in the nick of time, as I was about out of time to work on it. I'll give it's first real run on the machine tomorrow!
>
> It appears VS2008 has some important capabilities 2010Express does not. Perhaps it's time for me to move over.
>
> Brad,
>
> In looking at my code, you likely wondered "What the heck is that idiot doing re-creating all those DROs and buttons?". I imagine if you noticed it, you must think I'm a total frickin' moron. But, one annoying limitation of VS2010 is it does not allow you to create custom controls that you can put into the form designer. So my kludgey work-around was to use existing controls as placeholders, then subclass mine from those, and replace them at run time. Ugly, to be sure, but it works, and it saved time. One thing I WILL do real soon now is create the real controls in VS2008, and import them, then all that kludge code goes away.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Ray,
> > ÃÂ
> > BTW Winmerge.org is a simple free tool that I coun't live without.
> > ÃÂ
> > TK
> >
> > From: himykabibble <jagboy@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Monday, January 30, 2012 7:30 PM
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> > ÃÂ
> > Brad,
> >
> > Can you tell me which files you modified? They've all been "touched", and I don't have a decent diff tool.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > >
> > > I saw the deadlock as well. You also had timers competing with your worker thread.
> > >
> > >
> > > I got rid of all timers and re-routed the synchronous calls that were competing for the Kflop (and GUI) as Tom pointed out.
> > >
> > > I will upload your modified source.
> > >
> > > -Brad
> > >
> > >
> > >
> > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > >
> > > > Actually, I had also thought of running the PCComm Handler (Thats "Service KFlop Commands" in the below dump) using a worker thread. I think that would solve the problem, wouldn't it?
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > Ray, Here is your deadlock situation
> > > > > ÃâÃÂ
> > > > > Main Thread
> > > > > ÃâàÃâàDisplayTimer Tick
> > > > > ÃâàÃâàÃâàÃâàÃâàService KFLOP Commands
> > > > > ÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàGetPersistVar(100)
> > > > > ÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàWriteLineReadLine
> > > > > ÃâÃÂ
> > > > > WorkerThread
> > > > > ÃâàÃâàUpdateControls
> > > > > ÃâàÃâàÃâàÃâàÃâàGetCommandedSpindleRPM()
> > > > > ÃâàÃâàÃâàÃâàÃâàÃâàGetPersistVarAsFloat
> > > > > ÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàWriteLineReadLine
> > > > > ÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàOnKMCallbackÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàOnMessageÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàKMController_ConsoleMessageHandlerÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàConsoleMessageHandlerCallbackÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàUpdateDocument(
> ÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàÃâàProgramRunPageForm.Invoke(action);newAction( delegate()
> > > > > ÃâàÃâàÃâàÃâàÃâÃÂ
> > > > > ÃâÃÂ
> > > > > Main thread is waiting to talk to KFLOP but can't because the Worker thread is using it.
> > > > > Worker thread is waiting on the Main Thread to do a GUI operation before it finishes Talking to KFLOP
> > > > > ÃâÃÂ
> > > > > BTW I don't know if you were aware that in VS you can open Debug | Windows | Threads to see exactly where all the threads are at and click on each thread to see its call stack.
> > > > > ÃâÃÂ
> > > > > TK
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > ÃâÃÂ
> > > > > From: himykabibble <jagboy@>
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Sent: Monday, January 30, 2012 6:31 PM
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > ÃâÃÂ
> > > > > Tom,
> > > > >
> > > > > That's the conclusion I've been coming to as well. As I indicated earlier, totally inane changes in the code will affect the behavior. So it's not the code itself, but likely the timing of events. And with all the hangs I'm seeing a deadlock makes perfect sense. But how do I pin it down?
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > > Hi Ray/Brad,
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > I don't think starting DSP programs is the issue.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > I downloaded Ray's program and I can demonstrate the issue by pushing on the CW/CCW Spindle buttons which cause a DSP program to execute and which eventually sends back a Console Message.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > About every other time the application locks up in what appears to me to probably be a classic deadlock.ÃÆ'ââ¬Å¡ÃâàÃÆ'ââ¬Å¡ÃâàOne Thread did a WriteLineReadLine which resulted in aÃÆ'ââ¬Å¡ÃâàConsole Callback which is trying to "Invoke" to get the GUI to do something but the GUI thread is blocked trying to talk to KFLOP.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > Maybe Brad can explain his understanding of this Invoke stuff.ÃÆ'ââ¬Å¡ÃâàDoes the Thread block waiting for the GUI (which I guess is the "Main" thread) to process a Windows Message?
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > I'm thinking the ConsoleCallback should never do any GUI stuff.ÃÆ'ââ¬Å¡ÃâàAny thread might have called the KMotion Libraries to do something and end up calling the callback.
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > Regards
> > > > > > TK
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > >
> > > > > > From: himykabibble <jagboy@>
> > > > > > To: DynoMotion@yahoogroups.com
> > > > > > Sent: Monday, January 30, 2012 5:51 PM
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > Brad,
> > > > > >
> > > > > > ALL of my DSP programs are now started via invoke, and I still have the problem.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline.
> > > > > > >
> > > > > > >
> > > > > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause.
> > > > > > >
> > > > > > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue.
> > > > > > >
> > > > > > > Let me know if that works for you as well.
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Tom,
> > > > > > > >
> > > > > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox.
> > > > > > > >
> > > > > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why....
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > > > > > > >
> > > > > > > > > Hi Ray,
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > BTW the DSP printfs send unsolicited messages to the PC.ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâàWhenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response.ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâàIn that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI.ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâàMaybe change the ConsoleCallback to just discard the message to help narrow things down.
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > Regards
> > > > > > > > > TK
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > From: himykabibble <jagboy@>
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > ÃÆ'Ã'âââ¬Ã
¡ÃÆ'ââ¬Å¡ÃâÃÂ
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I thought the main issue we were working on was the printf's/PComm issues in
> > > > > > > > > > your user programs, has that situation improved at all?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Good that your MDI code works though.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I
> > > > > > > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI
> > > > > > > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is
> > > > > > > > > > using some [STAThread ] component..
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > > > > > > improves.
> > > > > > > > > > >
> > > > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > > > >
> > > > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > > > {
> > > > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > > > {
> > > > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > > > }
> > > > > > > > > > > else
> > > > > > > > > > > {
> > > > > > > > > > > action();
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > > > > >
> > > > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > > > {
> > > > > > > > > > > //Your existing code inside here
> > > > > > > > > > > }
> > > > > > > > > > > ));
> > > > > > > > > > >
> > > > > > > > > > > Let me know if this helps.
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > > > > problematic
> > > > > > > > > > > > procedures inside a console app.. Only crashes my winforms browserapp.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups.
> > > > > > > > > > My
> > > > > > > > > > > > handler does nothing more than one line of code that stuffs the String
> > > > > > > > > > > > argument into a TextBox. With that one line commented out, all is good.
> > > > > > > > > > But
> > > > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the app just
> > > > > > > > > > locks
> > > > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > > > > > > entirely. The callback does work as it should, until the app locks up.
> > > > > > > > > > Is
> > > > > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > Well it makes me happy to see someone besides me having strange things
> > > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it
> > > > > > > > > > will
> > > > > > > > > > > > fix mine as well.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > ,
> > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine,
> > > > > > > > > > it
> > > > > > > > > > > > only
> > > > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you
> > > > > > > > > > look
> > > > > > > > > > > > at
> > > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > > > > > > commands as
> > > > > > > > > > > > if
> > > > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Still, it does not explain why it works for me and not you using the
> > > > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll
> > > > > > > > > > try
> > > > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > -Brad
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > On
> > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually,
> > > > > > > > > > > > didn't
> > > > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > > > > InvokeAction a
> > > > > > > > > > > > > > better way to do it?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > > > > > > Non-motion
> > > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands
> > > > > > > > > > never
> > > > > > > > > > > > > > issue a Completed callback. The move IS completed, I get the status
> > > > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my
> > > > > > > > > > > > E-stop
> > > > > > > > > > > > > > button, or re-starting the App, THEN I get the completed callback.
> > > > > > > > > > So
> > > > > > > > > > > > > > something is blocking something there as well. This was working fine
> > > > > > > > > > > > until I
> > > > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going
> > > > > > > > > > on
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program
> > > > > > > > > > and
> > > > > > > > > > > > I
> > > > > > > > > > > > > > get
> > > > > > > > > > > > > > > the same result.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate
> > > > > > > > > > > > crash.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > It is interesting to note that we get the print messages just fine
> > > > > > > > > > > > from
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > > > > > > dirty
> > > > > > > > > > > > > > test::
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction
> > > > > > > > > > as
> > > > > > > > > > > > well?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > > On
> > > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or
> > > > > > > > > > > > shared
> > > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > > > > > > had
> > > > > > > > > > > > some
> > > > > > > > > > > > > > > printfs in the Home code that I had put in while beating on this
> > > > > > > > > > > > thing. I
> > > > > > > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > > > > > > changed.
> > > > > > > > > > > > > > printfs
> > > > > > > > > > > > > > > still do not come out in the KMotion console after I re-start my
> > > > > > > > > > app,
> > > > > > > > > > > > so
> > > > > > > > > > > > > > > there is something still not completely right, but PCComm is now
> > > > > > > > > > > > working,
> > > > > > > > > > > > > > so
> > > > > > > > > > > > > > > thanks for pointing me in the right direction. I just didn't even
> > > > > > > > > > > > really
> > > > > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > > > > KMotionCNC....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > > > > > > fine,
> > > > > > > > > > > > but
> > > > > > > > > > > > > > NOT
> > > > > > > > > > > > > > > see printfs? For that matter, when in that state, it does not see
> > > > > > > > > > DSP
> > > > > > > > > > > > > > tasks
> > > > > > > > > > > > > > > running either, as indficated as there are no green highlights on
> > > > > > > > > > the
> > > > > > > > > > > > task
> > > > > > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > > > > > > without
> > > > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > > > > > > time.
> > > > > > > > > > > > The
> > > > > > > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > > > > > > strangely in
> > > > > > > > > > > > any
> > > > > > > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > > > > > > But, if
> > > > > > > > > > > > I
> > > > > > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > still be able to talk to the board, and execute commands from the
> > > > > > > > > > > > console,
> > > > > > > > > > > > > > > but printfs from the DSP no longer show up in the console window,
> > > > > > > > > > > > until I
> > > > > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > > > > influencing
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > > > > > > wouldn't be
> > > > > > > > > > > > > > doing
> > > > > > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > > > > > > more
> > > > > > > > > > > > like a
> > > > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does
> > > > > > > > > > it
> > > > > > > > > > > > do
> > > > > > > > > > > > > > > after it sees the persist var cleared? What if you clear it from
> > > > > > > > > > the
> > > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > > Console instead? Otherwise I can look at if you post all the code.
> > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions
> > > > > > > > > > on
> > > > > > > > > > > > how
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works
> > > > > > > > > > just
> > > > > > > > > > > > > > fine.
> > > > > > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and
> > > > > > > > > > it
> > > > > > > > > > > > seems
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm
> > > > > > > > > > code
> > > > > > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after
> > > > > > > > > > > > that,
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to
> > > > > > > > > > run
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008,
> > > > > > > > > > even
> > > > > > > > > > > > > > though
> > > > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it
> > > > > > > > > > opens
> > > > > > > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger,
> > > > > > > > > > no
> > > > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > > > > > > having
> > > > > > > > > > > > both
> > > > > > > > > > > > > > > versions installed, but I not only don't know how to fix it, I am
> > > > > > > > > > > > > > reluctant
> > > > > > > > > > > > > > > to try to get 2008 working in that context, for fear it will screw
> > > > > > > > > > up
> > > > > > > > > > > > > > 2010,
> > > > > > > > > > > > > > > which is what I generally use. I only installed 2008 to be able to
> > > > > > > > > > > > build
> > > > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > > > > > > not
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is
> > > > > > > > > > that
> > > > > > > > > > > > is
> > > > > > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going
> > > > > > > > > > > > wrong,
> > > > > > > > > > > > > > or
> > > > > > > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > > > > > > comment
> > > > > > > > > > > > out
> > > > > > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the
> > > > > > > > > > > > problem
> > > > > > > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > > > > > > that
> > > > > > > > > > > > one
> > > > > > > > > > > > > > > line to write *any* other location, like 99, or 101, the failure
> > > > > > > > > > > > > > "signature"
> > > > > > > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > > > > > > Persist
> > > > > > > > > > > > > > location
> > > > > > > > > > > > > > > is written, the app continues to run normally until I close it.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting
> > > > > > > > > > and
> > > > > > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > > > > > > the
> > > > > > > > > > > > new
> > > > > > > > > > > > > > app
> > > > > > > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > > > > > > constructors
> > > > > > > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > > > > > > wrong
> > > > > > > > > > > > AFTER
> > > > > > > > > > > > > > > they have all run, and I don't know how to stop it at a point that
> > > > > > > > > > > > would
> > > > > > > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I
> > > > > > > > > > > > shifted
> > > > > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > > > > > > location. So
> > > > > > > > > > > > > > it's
> > > > > > > > > > > > > > > not the specific location that's at issue, it has to be something
> > > > > > > > > > > > > > connected
> > > > > > > > > > > > > > > with that functionality. But we know the DSP side works fine, and
> > > > > > > > > > the
> > > > > > > > > > > > PC
> > > > > > > > > > > > > > > side isn't actually *doing* anything, other than writing that one
> > > > > > > > > > > > word. So
> > > > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > > > > > > surrounded
> > > > > > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the
> > > > > > > > > > > > token
> > > > > > > > > > > > > > (the
> > > > > > > > > > > > > > > functions for doing Gather operations do use the token, but those
> > > > > > > > > > are
> > > > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > > > > > > running:
> > > > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display
> > > > > > > > > > > > (which
> > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > > > > > > rate,
> > > > > > > > > > > > mostly
> > > > > > > > > > > > > > > for periodically testing the connection, and updating the
> > > > > > > > > > "connected"
> > > > > > > > > > > > LED
> > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen
> > > > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > > > > > > methods
> > > > > > > > > > > > > > are
> > > > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > > > > > > that
> > > > > > > > > > > > would
> > > > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3641 |
From: Andrew Ford |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
I'm able to get the same hang in Kmotion with a printf every second or so. I didn't take too close a look at it in the debugger but it looks like a deadlock. I could take a closer look again tonight.
On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@...> wrote:
Hi Ray,
BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response.
So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down.
It isn't clear to me if the crash you report having in the MarshalPost is before the call or after.
Regards
TK
Group: DynoMotion |
Message: 3642 |
From: Brad Murry |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Hello Ray, I will look into your code then, as regrettably I cannot reproduce the same problems. -Brad Murry From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On Behalf Of himykabibble Sent: Monday, January 30, 2012 6:51 PM To: DynoMotion@yahoogroups.com Subject: [DynoMotion] Re: Need Some Ideas.... Brad,
ALL of my DSP programs are now started via invoke, and I still have the problem.
Regards, Ray L.
--- In DynoMotion@yahoogroups.com, "bradodarb" <bradodarb@...> wrote: > > Ray, > > It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline. > > > So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause. > > I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue. > > Let me know if that works for you as well. > > -Brad Murry > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote: > > > > Tom, > > > > Yes, if I comment out the console message handler it behaves better. The message handler is doing nothing but an invoke that stuffs the passed string into a textbox. > > > > Things are rather worse now.... I've been exercising some of the other GUI controls, and I'm getting hangs galore. I seem to be able to jog and do MDI, even using the DSP, with no problems, but using the minor controls is generating tons of hangs. I'm trying to figure out why.... > > > > Regards, > > Ray L. > > > > --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote: > > > > > > Hi Ray, > > >  > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response. > > >  > > > So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down. > > >  > > > It isn't clear to me if the crash you report having in the MarshalPost is before the call or after. > > >  > > > Regards > > > TK > > >  > > >  > > >  > > >  > > > From: himykabibble <jagboy@> > > > To: DynoMotion@yahoogroups.com > > > Sent: Monday, January 30, 2012 4:14 PM > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > >  > > > Brad, > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code. > > > > > > Regards, > > > Ray L. > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote: > > > > > > > > Ray, > > > > > > > > > > > > > > > > I thought the main issue we were working on was the printf's/PComm issues in > > > > your user programs, has that situation improved at all? > > > > > > > > > > > > > > > > Good that your MDI code works though. > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On > > > > Behalf Of himykabibble > > > > Sent: Monday, January 30, 2012 11:24 AM > > > > To: DynoMotion@yahoogroups.com > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I > > > > still get the hangs in CheckIsRead() when I have the console callback > > > > updating the TextBox, even though it is now also being invoked. > > > > > > > > Regards, > > > > Ray L. > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > > > > "bradodarb" <bradodarb@> wrote: > > > > > > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to > > > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI > > > > components, but in my case an HTML button is being clicked, handled by > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf is > > > > using some [STAThread ] component.. > > > > > > > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it > > > > improves. > > > > > > > > > > Here is a nice tidy way to do it:: > > > > > > > > > > public void UpdateDocument(Action action) > > > > > { > > > > > if (_GuiHost.Parent.InvokeRequired) > > > > > { > > > > > _GuiHost.Parent.Invoke(action); > > > > > } > > > > > else > > > > > { > > > > > action(); > > > > > } > > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. :: > > > > > > > > > > UpdateDocument(new Action(delegate() > > > > > { > > > > > //Your existing code inside here > > > > > } > > > > > )); > > > > > > > > > > Let me know if this helps. > > > > > > > > > > -Brad Murry > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > You should invoke it to your textbox. > > > > > > > > > > > > > > > > > > > > > > > > In related news, I have no issues running any of my previously > > > > problematic > > > > > > procedures inside a console app.. Only crashes my winforms browserapp. > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ] > > > > On > > > > > > Behalf Of himykabibble > > > > > > Sent: Monday, January 30, 2012 10:18 AM > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups. > > > > My > > > > > > handler does nothing more than one line of code that stuffs the String > > > > > > argument into a TextBox. With that one line commented out, all is good. > > > > But > > > > > > if I uncomment that one line, then I get frequent hangs - the app just > > > > locks > > > > > > up. No errors, exceptions, or anything but the GUI stops responding > > > > > > entirely. The callback does work as it should, until the app locks up. > > > > Is > > > > > > this a threading thing? Nobody else writes to that TextBox. > > > > > > > > > > > > Regards, > > > > > > Ray L. > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > Well it makes me happy to see someone besides me having strange things > > > > > > happening! :-) Hopefully when you get to the bottom of your problem it > > > > will > > > > > > fix mine as well. > > > > > > > > > > > > > > Regards, > > > > > > > Ray L. > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > , > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine, > > > > it > > > > > > only > > > > > > > > crashes when I use the InvokeAction. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you > > > > look > > > > > > at > > > > > > > > the Ccode, it populates the MCodeActions as fires the button > > > > commands as > > > > > > if > > > > > > > > they were any other MCode. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Still, it does not explain why it works for me and not you using the > > > > > > > > CompileAndLoadCoff. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll > > > > try > > > > > > > > that and get back to you. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > On > > > > > > > > Behalf Of himykabibble > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually, > > > > > > didn't > > > > > > > > even know how to, but now I do! Cool!). > > > > > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is > > > > InvokeAction a > > > > > > > > better way to do it? > > > > > > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one > > > > > > > > backward.... MDI commands, which WERE working fine, now are not. > > > > > > Non-motion > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands > > > > never > > > > > > > > issue a Completed callback. The move IS completed, I get the status > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting my > > > > > > E-stop > > > > > > > > button, or re-starting the App, THEN I get the completed callback. > > > > So > > > > > > > > something is blocking something there as well. This was working fine > > > > > > until I > > > > > > > > fixed the original PCComm problem. > > > > > > > > > > > > > > > > Regards, > > > > > > > > Ray L. > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going > > > > on > > > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program > > > > and > > > > > > I > > > > > > > > get > > > > > > > > > the same result. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Do you have the message event wired up? - > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _Controller.MessageUpdated += new > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate > > > > > > crash. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > It is interesting to note that we get the print messages just fine > > > > > > from > > > > > > > > the > > > > > > > > > c# console application. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and > > > > dirty > > > > > > > > test:: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C > > > > > > > > > Programs\KMotionCNC\print.c"; > > > > > > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1, > > > > > > > > > TheCFile, false)); > > > > > > > > > > > > > > > > > > //Excecute the program we just loaded > > > > > > > > > > > > > > > > > > _Controller.WriteLine("Execute1"); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy > > > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction > > > > as > > > > > > well? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > [mailto:DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > > > On > > > > > > > > > Behalf Of himykabibble > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM > > > > > > > > > To: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or > > > > > > shared > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I > > > > had > > > > > > some > > > > > > > > > printfs in the Home code that I had put in while beating on this > > > > > > thing. I > > > > > > > > > just took them out, and it's now working. Nothing else has > > > > changed. > > > > > > > > printfs > > > > > > > > > still do not come out in the KMotion console after I re-start my > > > > app, > > > > > > so > > > > > > > > > there is something still not completely right, but PCComm is now > > > > > > working, > > > > > > > > so > > > > > > > > > thanks for pointing me in the right direction. I just didn't even > > > > > > really > > > > > > > > > consider the DSP Code, because it's always worked under > > > > KMotionCNC.... > > > > > > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just > > > > fine, > > > > > > but > > > > > > > > NOT > > > > > > > > > see printfs? For that matter, when in that state, it does not see > > > > DSP > > > > > > > > tasks > > > > > > > > > running either, as indficated as there are no green highlights on > > > > the > > > > > > task > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion, > > > > without > > > > > > > > > restarting my app, all is well. > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under > > > > > > > > KMotionCNC. > > > > > > > > > But, just to be sure, I went to a three line program: > > > > > > > > > > > > > > > > > > > > main() > > > > > > > > > > { > > > > > > > > > > printf("Doing MsgBox\n"); > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK); > > > > > > > > > > printf("MsgBox Done\n"); > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > This gives a different result. The first printf appears every > > > > time. > > > > > > The > > > > > > > > > second one never appears. My app does not crash or behave > > > > strangely in > > > > > > any > > > > > > > > > way that I can see, even if I open and close it several times. > > > > But, if > > > > > > I > > > > > > > > > open KMotion, then open my app, then close it, then re-open it, > > > > > > KMotion > > > > > > > > will > > > > > > > > > still be able to talk to the board, and execute commands from the > > > > > > console, > > > > > > > > > but printfs from the DSP no longer show up in the console window, > > > > > > until I > > > > > > > > > close then re-open KMotion. Does that make any sense? > > > > > > > > > > > > > > > > > > > > I will try to narrow down what in the Home program is > > > > influencing > > > > > > the > > > > > > > > > PCComm stuff. But what could that program be doing that it > > > > wouldn't be > > > > > > > > doing > > > > > > > > > when run under KMotionCNC, where it's always works perfectly?? > > > > > > > > > > > > > > > > > > > > I'll post the code tomorrow. > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > TK <tk@> wrote: > > > > > > > > > > > > > > > > > > > > > > Hi Ray, > > > > > > > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds > > > > more > > > > > > like a > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does > > > > it > > > > > > do > > > > > > > > > after it sees the persist var cleared? What if you clear it from > > > > the > > > > > > > > KMotion > > > > > > > > > Console instead? Otherwise I can look at if you post all the code. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > TK > > > > > > > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > > > > > > > > Tom/Brad, > > > > > > > > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions > > > > on > > > > > > how > > > > > > > > to > > > > > > > > > proceed. As long as I don't touch Persist[100], everything works > > > > just > > > > > > > > fine. > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, and > > > > it > > > > > > seems > > > > > > > > to > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm > > > > code > > > > > > > > > correctly processes it, and clears Persist[100], and shortly after > > > > > > that, > > > > > > > > the > > > > > > > > > board "goes missing", and I get the dialog asking me if I want to > > > > run > > > > > > the > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008, > > > > even > > > > > > > > though > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it > > > > opens > > > > > > > > > VS2008, loads the current source file, and that's it. No debugger, > > > > no > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to > > > > having > > > > > > both > > > > > > > > > versions installed, but I not only don't know how to fix it, I am > > > > > > > > reluctant > > > > > > > > > to try to get 2008 working in that context, for fear it will screw > > > > up > > > > > > > > 2010, > > > > > > > > > which is what I generally use. I only installed 2008 to be able to > > > > > > build > > > > > > > > > KMotion, and otherwise don't use it. > > > > > > > > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while > > > > not > > > > > > the > > > > > > > > > actual cause of the problem, is somehow triggering whatever it is > > > > that > > > > > > is > > > > > > > > > going wrong, but I'm totally at a loss to understand what is going > > > > > > wrong, > > > > > > > > or > > > > > > > > > how, and have had no success in trying to narrow it down. If I > > > > comment > > > > > > out > > > > > > > > > the one line that clears Persist[100] after a PCComm command, the > > > > > > problem > > > > > > > > > goes away entirely, and everything works perfectly. If I change > > > > that > > > > > > one > > > > > > > > > line to write *any* other location, like 99, or 101, the failure > > > > > > > > "signature" > > > > > > > > > changes - rather than crashing almost immediately after the > > > > Persist > > > > > > > > location > > > > > > > > > is written, the app continues to run normally until I close it. > > > > > > > > > > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting > > > > and > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as > > > > the > > > > > > new > > > > > > > > app > > > > > > > > > instance recognizes the connection is available, and does its > > > > > > > > KM_Controller > > > > > > > > > initialization. I've stepped through all the init code and the > > > > > > > > constructors > > > > > > > > > on that second start-up, and whatever is going wrong is going > > > > wrong > > > > > > AFTER > > > > > > > > > they have all run, and I don't know how to stop it at a point that > > > > > > would > > > > > > > > > give me any useful information about what is going wrong. > > > > > > > > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I > > > > > > shifted > > > > > > > > > it from Var 100 to 80), the problem follows it to the new > > > > location. So > > > > > > > > it's > > > > > > > > > not the specific location that's at issue, it has to be something > > > > > > > > connected > > > > > > > > > with that functionality. But we know the DSP side works fine, and > > > > the > > > > > > PC > > > > > > > > > side isn't actually *doing* anything, other than writing that one > > > > > > word. So > > > > > > > > > what the heck is really happening? > > > > > > > > > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are > > > > > > surrounded > > > > > > > > > with locks, and I'm not doing anything that requires grabbing the > > > > > > token > > > > > > > > (the > > > > > > > > > functions for doing Gather operations do use the token, but those > > > > are > > > > > > > > > commented out now). > > > > > > > > > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads > > > > > > running: > > > > > > > > > > > > 1) The main app thread > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath display > > > > > > (which > > > > > > > > is > > > > > > > > > basically idle, since the toolpath window is not open) > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates > > > > > > > > > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec > > > > rate, > > > > > > mostly > > > > > > > > > for periodically testing the connection, and updating the > > > > "connected" > > > > > > LED > > > > > > > > in > > > > > > > > > the GUI, and showing me the GUI state through a set of on-screen > > > > > > > > checkboxes. > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer > > > > > > methods > > > > > > > > are > > > > > > > > > very simple and lightweight. > > > > > > > > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if > > > > that > > > > > > would > > > > > > > > > help. I'm truly stuck on this one. > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
|
|
Group: DynoMotion |
Message: 3643 |
From: Brad Murry |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Ray, It is likely that my previous posts were not linked to the printf issue as they were a bit out of order int the timeline. So, I was having the same problem before until I surrounded the code that makes calls to .c programs containing printfs with an invoke clause. I believe the printf unsolicited callbacks are pumping a message on a non STAThread, which is a big no-no on the .net side. This is just a theory, but forcing them to be executed in the GUI thread(via invoke) seems to resolve the issue. Let me know if that works for you as well. -Brad Murry From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On Behalf Of himykabibble Sent: Monday, January 30, 2012 5:31 PM To: DynoMotion@yahoogroups.com Subject: [DynoMotion] Re: Need Some Ideas.... I've just posted my current code, with all the locks removed. The only and only issue appears to be that using printf in DSP code induces a hang in WriteLineReadLine().
Regards, Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote: > > Brad, > > As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code. > > Regards, > Ray L. > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote: > > > > Ray, > > > > > > > > I thought the main issue we were working on was the printf's/PComm issues in > > your user programs, has that situation improved at all? > > > > > > > > Good that your MDI code works though. > > > > > > > > -Brad > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On > > Behalf Of himykabibble > > Sent: Monday, January 30, 2012 11:24 AM > > To: DynoMotion@yahoogroups.com > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > Brad, > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I > > still get the hangs in CheckIsRead() when I have the console callback > > updating the TextBox, even though it is now also being invoked. > > > > Regards, > > Ray L. > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > > "bradodarb" <bradodarb@> wrote: > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to > > invoke them. Kinda weird, you usually only need to invoke calls to your GUI > > components, but in my case an HTML button is being clicked, handled by > > jscript COM marshaling over to a method in my c# code. Maybe the printf is > > using some [STAThread ] component.. > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it > > improves. > > > > > > Here is a nice tidy way to do it:: > > > > > > public void UpdateDocument(Action action) > > > { > > > if (_GuiHost.Parent.InvokeRequired) > > > { > > > _GuiHost.Parent.Invoke(action); > > > } > > > else > > > { > > > action(); > > > } > > > > > > And then in your code that runs the CompileAndLoad, etc.. :: > > > > > > UpdateDocument(new Action(delegate() > > > { > > > //Your existing code inside here > > > } > > > )); > > > > > > Let me know if this helps. > > > > > > -Brad Murry > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > > Brad Murry <bradodarb@> wrote: > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > You should invoke it to your textbox. > > > > > > > > > > > > > > > > In related news, I have no issues running any of my previously > > problematic > > > > procedures inside a console app.. Only crashes my winforms browserapp. > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ] > > On > > > > Behalf Of himykabibble > > > > Sent: Monday, January 30, 2012 10:18 AM > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > I wired in the console message handler, and I now get frequent lock-ups. > > My > > > > handler does nothing more than one line of code that stuffs the String > > > > argument into a TextBox. With that one line commented out, all is good. > > But > > > > if I uncomment that one line, then I get frequent hangs - the app just > > locks > > > > up. No errors, exceptions, or anything but the GUI stops responding > > > > entirely. The callback does work as it should, until the app locks up. > > Is > > > > this a threading thing? Nobody else writes to that TextBox. > > > > > > > > Regards, > > > > Ray L. > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > <mailto:DynoMotion%40yahoogroups.com> , > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > Brad, > > > > > > > > > > Well it makes me happy to see someone besides me having strange things > > > > happening! :-) Hopefully when you get to the bottom of your problem it > > will > > > > fix mine as well. > > > > > > > > > > Regards, > > > > > Ray L. > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > , > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine, > > it > > > > only > > > > > > crashes when I use the InvokeAction. > > > > > > > > > > > > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you > > look > > > > at > > > > > > the Ccode, it populates the MCodeActions as fires the button > > commands as > > > > if > > > > > > they were any other MCode. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Still, it does not explain why it works for me and not you using the > > > > > > CompileAndLoadCoff. > > > > > > > > > > > > > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll > > try > > > > > > that and get back to you. > > > > > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > On > > > > > > Behalf Of himykabibble > > > > > > Sent: Monday, January 30, 2012 9:21 AM > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually, > > > > didn't > > > > > > even know how to, but now I do! Cool!). > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is > > InvokeAction a > > > > > > better way to do it? > > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one > > > > > > backward.... MDI commands, which WERE working fine, now are not. > > > > Non-motion > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands > > never > > > > > > issue a Completed callback. The move IS completed, I get the status > > > > > > callback, then nothing. When I halt the interpreter, by hitting my > > > > E-stop > > > > > > button, or re-starting the App, THEN I get the completed callback. > > So > > > > > > something is blocking something there as well. This was working fine > > > > until I > > > > > > fixed the original PCComm problem. > > > > > > > > > > > > Regards, > > > > > > Ray L. > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going > > on > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program > > and > > > > I > > > > > > get > > > > > > > the same result. > > > > > > > > > > > > > > > > > > > > > > > > > > > > Do you have the message event wired up? - > > > > > > > > > > > > > > > > > > > > > > > > > > > > _Controller.MessageUpdated += new > > > > > > > KMConsoleHandler(_Controller_MessageUpdated); > > > > > > > > > > > > > > > > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate > > > > crash. > > > > > > > > > > > > > > > > > > > > > > > > > > > > It is interesting to note that we get the print messages just fine > > > > from > > > > > > the > > > > > > > c# console application. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and > > dirty > > > > > > test:: > > > > > > > > > > > > > > > > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C > > > > > > > Programs\KMotionCNC\print.c"; > > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1, > > > > > > > TheCFile, false)); > > > > > > > > > > > > > > //Excecute the program we just loaded > > > > > > > > > > > > > > _Controller.WriteLine("Execute1"); > > > > > > > > > > > > > > > > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes). > > > > > > > > > > > > > > > > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction > > as > > > > well? > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > [mailto:DynoMotion@yahoogroups.com > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > On > > > > > > > Behalf Of himykabibble > > > > > > > Sent: Monday, January 30, 2012 1:03 AM > > > > > > > To: DynoMotion@yahoogroups.com > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or > > > > shared > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I > > had > > > > some > > > > > > > printfs in the Home code that I had put in while beating on this > > > > thing. I > > > > > > > just took them out, and it's now working. Nothing else has > > changed. > > > > > > printfs > > > > > > > still do not come out in the KMotion console after I re-start my > > app, > > > > so > > > > > > > there is something still not completely right, but PCComm is now > > > > working, > > > > > > so > > > > > > > thanks for pointing me in the right direction. I just didn't even > > > > really > > > > > > > consider the DSP Code, because it's always worked under > > KMotionCNC.... > > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just > > fine, > > > > but > > > > > > NOT > > > > > > > see printfs? For that matter, when in that state, it does not see > > DSP > > > > > > tasks > > > > > > > running either, as indficated as there are no green highlights on > > the > > > > task > > > > > > > IDs next to the editor window. But after re-starting Kmotion, > > without > > > > > > > restarting my app, all is well. > > > > > > > > > > > > > > Regards, > > > > > > > Ray L. > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under > > > > > > KMotionCNC. > > > > > > > But, just to be sure, I went to a three line program: > > > > > > > > > > > > > > > > main() > > > > > > > > { > > > > > > > > printf("Doing MsgBox\n"); > > > > > > > > MsgBox("This is my MessageBox", MB_OK); > > > > > > > > printf("MsgBox Done\n"); > > > > > > > > } > > > > > > > > > > > > > > > > This gives a different result. The first printf appears every > > time. > > > > The > > > > > > > second one never appears. My app does not crash or behave > > strangely in > > > > any > > > > > > > way that I can see, even if I open and close it several times. > > But, if > > > > I > > > > > > > open KMotion, then open my app, then close it, then re-open it, > > > > KMotion > > > > > > will > > > > > > > still be able to talk to the board, and execute commands from the > > > > console, > > > > > > > but printfs from the DSP no longer show up in the console window, > > > > until I > > > > > > > close then re-open KMotion. Does that make any sense? > > > > > > > > > > > > > > > > I will try to narrow down what in the Home program is > > influencing > > > > the > > > > > > > PCComm stuff. But what could that program be doing that it > > wouldn't be > > > > > > doing > > > > > > > when run under KMotionCNC, where it's always works perfectly?? > > > > > > > > > > > > > > > > I'll post the code tomorrow. > > > > > > > > > > > > > > > > Regards, > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > <mailto:DynoMotion%40yahoogroups.com> > > > > <mailto:DynoMotion%40yahoogroups.com> > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > TK <tk@> wrote: > > > > > > > > > > > > > > > > > > Hi Ray, > > > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds > > more > > > > like a > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does > > it > > > > do > > > > > > > after it sees the persist var cleared? What if you clear it from > > the > > > > > > KMotion > > > > > > > Console instead? Otherwise I can look at if you post all the code. > > > > > > > > > > > > > > > > > > > > > > > > > > > > TK > > > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > > > > Tom/Brad, > > > > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions > > on > > > > how > > > > > > to > > > > > > > proceed. As long as I don't touch Persist[100], everything works > > just > > > > > > fine. > > > > > > > I can start my app, run programs, exit, connect, disconnect, and > > it > > > > seems > > > > > > to > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm > > code > > > > > > > correctly processes it, and clears Persist[100], and shortly after > > > > that, > > > > > > the > > > > > > > board "goes missing", and I get the dialog asking me if I want to > > run > > > > the > > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008, > > even > > > > > > though > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it > > opens > > > > > > > VS2008, loads the current source file, and that's it. No debugger, > > no > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to > > having > > > > both > > > > > > > versions installed, but I not only don't know how to fix it, I am > > > > > > reluctant > > > > > > > to try to get 2008 working in that context, for fear it will screw > > up > > > > > > 2010, > > > > > > > which is what I generally use. I only installed 2008 to be able to > > > > build > > > > > > > KMotion, and otherwise don't use it. > > > > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while > > not > > > > the > > > > > > > actual cause of the problem, is somehow triggering whatever it is > > that > > > > is > > > > > > > going wrong, but I'm totally at a loss to understand what is going > > > > wrong, > > > > > > or > > > > > > > how, and have had no success in trying to narrow it down. If I > > comment > > > > out > > > > > > > the one line that clears Persist[100] after a PCComm command, the > > > > problem > > > > > > > goes away entirely, and everything works perfectly. If I change > > that > > > > one > > > > > > > line to write *any* other location, like 99, or 101, the failure > > > > > > "signature" > > > > > > > changes - rather than crashing almost immediately after the > > Persist > > > > > > location > > > > > > > is written, the app continues to run normally until I close it. > > > > > > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting > > and > > > > > > > reconnecting the board, I get the debug dialog again as soon as > > the > > > > new > > > > > > app > > > > > > > instance recognizes the connection is available, and does its > > > > > > KM_Controller > > > > > > > initialization. I've stepped through all the init code and the > > > > > > constructors > > > > > > > on that second start-up, and whatever is going wrong is going > > wrong > > > > AFTER > > > > > > > they have all run, and I don't know how to stop it at a point that > > > > would > > > > > > > give me any useful information about what is going wrong. > > > > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I > > > > shifted > > > > > > > it from Var 100 to 80), the problem follows it to the new > > location. So > > > > > > it's > > > > > > > not the specific location that's at issue, it has to be something > > > > > > connected > > > > > > > with that functionality. But we know the DSP side works fine, and > > the > > > > PC > > > > > > > side isn't actually *doing* anything, other than writing that one > > > > word. So > > > > > > > what the heck is really happening? > > > > > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are > > > > surrounded > > > > > > > with locks, and I'm not doing anything that requires grabbing the > > > > token > > > > > > (the > > > > > > > functions for doing Gather operations do use the token, but those > > are > > > > > > > commented out now). > > > > > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads > > > > running: > > > > > > > > > > 1) The main app thread > > > > > > > > > > 2) A thread running the WCF server for the toolpath display > > > > (which > > > > > > is > > > > > > > basically idle, since the toolpath window is not open) > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates > > > > > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec > > rate, > > > > mostly > > > > > > > for periodically testing the connection, and updating the > > "connected" > > > > LED > > > > > > in > > > > > > > the GUI, and showing me the GUI state through a set of on-screen > > > > > > checkboxes. > > > > > > > This thread is the one that calls the PCComm handler. All Timer > > > > methods > > > > > > are > > > > > > > very simple and lightweight. > > > > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if > > that > > > > would > > > > > > > help. I'm truly stuck on this one. > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
|
|
Group: DynoMotion |
Message: 3644 |
From: himykabibble |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Unfortunately, my celebration turns out to be a bit premature. My deadlocks are back, after making a few minor changes.... I also noticed today while running on the machine that DRO updates are still very slow - on the order to 2-3 updates/seconds. I suspect there's a lot of waiting going on somewhere in there.
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Andrew Ford <ahford@...> wrote:
>
> I'm able to get the same hang in Kmotion with a printf every second or so.
> I didn't take too close a look at it in the debugger but it looks like a
> deadlock. I could take a closer look again tonight.
>
> On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@...> wrote:
>
> > **
> >
> >
> > Hi Ray,
> >
> > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App
> > does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and
> > may get back the unsolicited message instead of the expected response. In
> > that case the unsolicited message received will be sent to the App via the
> > ConsoleCallback and then another read will be performed to get the expected
> > response.
> >
> > So from your description it seems like the crash is somehow being caused
> > by the ConsoleCallback possibly due to a bug in the .Net interface or
> > because the Console is doing something bad in your GUI. Maybe change the
> > ConsoleCallback to just discard the message to help narrow things down.
> >
> > It isn't clear to me if the crash you report having in the MarshalPost is
> > before the call or after.
> >
> > Regards
> > TK
> >
> >
> >
> >
> > *From:* himykabibble <jagboy@...>
> > *To:* DynoMotion@yahoogroups.com
> > *Sent:* Monday, January 30, 2012 4:14 PM
> >
> > *Subject:* [DynoMotion] Re: Need Some Ideas....
> >
> >
> > Brad,
> >
> > As of last night, thanks to Toms suggestion to look at the DSP code,
> > PCComm works, as does MDI from the DSP (and I assume most of the other
> > functions, though I haven't tested them all yet). (Mind you, that same DSP
> > code, printfs and all, works perfectly under KMotionCNC...) PCComm was
> > "fixed" by getting rid of the printfs in the DSP code. Put the printfs
> > back, and it starts locking up again (in CheckIsReady() before, but now in
> > MarshalPost within WriteLineReadLine - At least it's a dead-consistent
> > failure!). Console messages also work fine, as long as there are NO printfs
> > in the DSP code.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > >
> > > Ray,
> > >
> > >
> > >
> > > I thought the main issue we were working on was the printf's/PComm
> > issues in
> > > your user programs, has that situation improved at all?
> > >
> > >
> > >
> > > Good that your MDI code works though.
> > >
> > >
> > >
> > > -Brad
> > >
> > >
> > >
> > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > Behalf Of himykabibble
> > > Sent: Monday, January 30, 2012 11:24 AM
> > > To: DynoMotion@yahoogroups.com
> > > Subject: [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > >
> > >
> > >
> > > Brad,
> > >
> > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem,
> > but I
> > > still get the hangs in CheckIsRead() when I have the console callback
> > > updating the TextBox, even though it is now also being invoked.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > ,
> > > "bradodarb" <bradodarb@> wrote:
> > > >
> > > >
> > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > invoke them. Kinda weird, you usually only need to invoke calls to your
> > GUI
> > > components, but in my case an HTML button is being clicked, handled by
> > > jscript COM marshaling over to a method in my c# code. Maybe the printf
> > is
> > > using some [STAThread ] component..
> > > >
> > > >
> > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > improves.
> > > >
> > > > Here is a nice tidy way to do it::
> > > >
> > > > public void UpdateDocument(Action action)
> > > > {
> > > > if (_GuiHost.Parent.InvokeRequired)
> > > > {
> > > > _GuiHost.Parent.Invoke(action);
> > > > }
> > > > else
> > > > {
> > > > action();
> > > > }
> > > >
> > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > >
> > > > UpdateDocument(new Action(delegate()
> > > > {
> > > > //Your existing code inside here
> > > > }
> > > > ));
> > > >
> > > > Let me know if this helps.
> > > >
> > > > -Brad Murry
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > ,
> > > Brad Murry <bradodarb@> wrote:
> > > > >
> > > > > Hello Ray,
> > > > >
> > > > >
> > > > >
> > > > > You should invoke it to your textbox.
> > > > >
> > > > >
> > > > >
> > > > > In related news, I have no issues running any of my previously
> > > problematic
> > > > > procedures inside a console app.. Only crashes my winforms
> > browserapp.
> > > > >
> > > > >
> > > > >
> > > > > -Brad Murry
> > > > >
> > > > >
> > > > >
> > > > > From: DynoMotion@yahoogroups.com <mailto:
> > DynoMotion%40yahoogroups.com>
> > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > ]
> > > On
> > > > > Behalf Of himykabibble
> > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> >
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Brad,
> > > > >
> > > > > I wired in the console message handler, and I now get frequent
> > lock-ups.
> > > My
> > > > > handler does nothing more than one line of code that stuffs the
> > String
> > > > > argument into a TextBox. With that one line commented out, all is
> > good.
> > > But
> > > > > if I uncomment that one line, then I get frequent hangs - the app
> > just
> > > locks
> > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > entirely. The callback does work as it should, until the app locks
> > up.
> > > Is
> > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:
> > DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > "himykabibble" <jagboy@> wrote:
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > Well it makes me happy to see someone besides me having strange
> > things
> > > > > happening! :-) Hopefully when you get to the bottom of your problem
> > it
> > > will
> > > > > fix mine as well.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > DynoMotion%40yahoogroups.com>
> > > ,
> > > > > Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Interesting, if I use CompileAndLoadCoff everything works just
> > fine,
> > > it
> > > > > only
> > > > > > > crashes when I use the InvokeAction.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If
> > you
> > > look
> > > > > at
> > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > commands as
> > > > > if
> > > > > > > they were any other MCode.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Still, it does not explain why it works for me and not you using
> > the
> > > > > > > CompileAndLoadCoff.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Then again, I am not using any PComm in my test prog(print.c).
> > I'll
> > > try
> > > > > > > that and get back to you.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > DynoMotion%40yahoogroups.com>
> > > > > [mailto:DynoMotion@yahoogroups.com <mailto:
> > DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > To: DynoMotion@yahoogroups.com <mailto:
> > DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > No, I do not have the message event hooked up in my app.
> > (Actually,
> > > > > didn't
> > > > > > > even know how to, but now I do! Cool!).
> > > > > > >
> > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > InvokeAction a
> > > > > > > better way to do it?
> > > > > > >
> > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > Non-motion
> > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> > commands
> > > never
> > > > > > > issue a Completed callback. The move IS completed, I get the
> > status
> > > > > > > callback, then nothing. When I halt the interpreter, by hitting
> > my
> > > > > E-stop
> > > > > > > button, or re-starting the App, THEN I get the completed
> > callback.
> > > So
> > > > > > > something is blocking something there as well. This was working
> > fine
> > > > > until I
> > > > > > > fixed the original PCComm problem.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Hello Ray,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I am wondering if there are some .net memory sharing issues
> > going
> > > on
> > > > > here.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I just set one of my user buttons to fire off the print.c
> > program
> > > and
> > > > > I
> > > > > > > get
> > > > > > > > the same result.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Do you have the message event wired up? -
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I do, and I get the Hello, World message followed by an
> > immediate
> > > > > crash.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > It is interesting to note that we get the print messages just
> > fine
> > > > > from
> > > > > > > the
> > > > > > > > c# console application.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > So I tried this code in my button event handler as a quick and
> > > dirty
> > > > > > > test::
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > >
> > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > TheCFile, false));
> > > > > > > >
> > > > > > > > //Excecute the program we just loaded
> > > > > > > >
> > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I looks like InvokeAction with printf's are doing something
> > screwy
> > > > > here.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Ray- Are you invoking your cprogram via
> > Interpreter.InvokeAction
> > > as
> > > > > well?
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > To: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Tom,
> > > > > > > >
> > > > > > > > I know this is a stupid question, but is there some
> > interaction or
> > > > > shared
> > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > had
> > > > > some
> > > > > > > > printfs in the Home code that I had put in while beating on
> > this
> > > > > thing. I
> > > > > > > > just took them out, and it's now working. Nothing else has
> > > changed.
> > > > > > > printfs
> > > > > > > > still do not come out in the KMotion console after I re-start
> > my
> > > app,
> > > > > so
> > > > > > > > there is something still not completely right, but PCComm is
> > now
> > > > > working,
> > > > > > > so
> > > > > > > > thanks for pointing me in the right direction. I just didn't
> > even
> > > > > really
> > > > > > > > consider the DSP Code, because it's always worked under
> > > KMotionCNC....
> > > > > > > >
> > > > > > > > What could cause KMotion to be able to talk to the board just
> > > fine,
> > > > > but
> > > > > > > NOT
> > > > > > > > see printfs? For that matter, when in that state, it does not
> > see
> > > DSP
> > > > > > > tasks
> > > > > > > > running either, as indficated as there are no green highlights
> > on
> > > the
> > > > > task
> > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > without
> > > > > > > > restarting my app, all is well.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > >
> > > > > > > > > Tom,
> > > > > > > > >
> > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > KMotionCNC.
> > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > >
> > > > > > > > > main()
> > > > > > > > > {
> > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > This gives a different result. The first printf appears every
> > > time.
> > > > > The
> > > > > > > > second one never appears. My app does not crash or behave
> > > strangely in
> > > > > any
> > > > > > > > way that I can see, even if I open and close it several times.
> > > But, if
> > > > > I
> > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > KMotion
> > > > > > > will
> > > > > > > > still be able to talk to the board, and execute commands from
> > the
> > > > > console,
> > > > > > > > but printfs from the DSP no longer show up in the console
> > window,
> > > > > until I
> > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > >
> > > > > > > > > I will try to narrow down what in the Home program is
> > > influencing
> > > > > the
> > > > > > > > PCComm stuff. But what could that program be doing that it
> > > wouldn't be
> > > > > > > doing
> > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > >
> > > > > > > > > I'll post the code tomorrow.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > TK <tk@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hi Ray,
> > > > > > > > > >
> > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > more
> > > > > like a
> > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What
> > does
> > > it
> > > > > do
> > > > > > > > after it sees the persist var cleared? What if you clear it
> > from
> > > the
> > > > > > > KMotion
> > > > > > > > Console instead? Otherwise I can look at if you post all the
> > code.
> > >
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > TK
> > > > > > > > > >
> > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@>
> > wrote:
> > > > > > > > > >
> > > > > > > > > > > Tom/Brad,
> > > > > > > > > > >
> > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> > suggestions
> > > on
> > > > > how
> > > > > > > to
> > > > > > > > proceed. As long as I don't touch Persist[100], everything
> > works
> > > just
> > > > > > > fine.
> > > > > > > > I can start my app, run programs, exit, connect, disconnect,
> > and
> > > it
> > > > > seems
> > > > > > > to
> > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my
> > PCComm
> > > code
> > > > > > > > correctly processes it, and clears Persist[100], and shortly
> > after
> > > > > that,
> > > > > > > the
> > > > > > > > board "goes missing", and I get the dialog asking me if I want
> > to
> > > run
> > > > > the
> > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> > VS2008,
> > > even
> > > > > > > though
> > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt,
> > it
> > > opens
> > > > > > > > VS2008, loads the current source file, and that's it. No
> > debugger,
> > > no
> > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > having
> > > > > both
> > > > > > > > versions installed, but I not only don't know how to fix it, I
> > am
> > > > > > > reluctant
> > > > > > > > to try to get 2008 working in that context, for fear it will
> > screw
> > > up
> > > > > > > 2010,
> > > > > > > > which is what I generally use. I only installed 2008 to be
> > able to
> > > > > build
> > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > >
> > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > not
> > > > > the
> > > > > > > > actual cause of the problem, is somehow triggering whatever it
> > is
> > > that
> > > > > is
> > > > > > > > going wrong, but I'm totally at a loss to understand what is
> > going
> > > > > wrong,
> > > > > > > or
> > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > comment
> > > > > out
> > > > > > > > the one line that clears Persist[100] after a PCComm command,
> > the
> > > > > problem
> > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > that
> > > > > one
> > > > > > > > line to write *any* other location, like 99, or 101, the
> > failure
> > > > > > > "signature"
> > > > > > > > changes - rather than crashing almost immediately after the
> > > Persist
> > > > > > > location
> > > > > > > > is written, the app continues to run normally until I close
> > it.
> > > > > > > > > > >
> > > > > > > > > > > But, if I then re-start the app without first
> > disconnecting
> > > and
> > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > the
> > > > > new
> > > > > > > app
> > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > KM_Controller
> > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > constructors
> > > > > > > > on that second start-up, and whatever is going wrong is going
> > > wrong
> > > > > AFTER
> > > > > > > > they have all run, and I don't know how to stop it at a point
> > that
> > > > > would
> > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > >
> > > > > > > > > > > Not surprisingly, if I change the location used for
> > PComm (I
> > > > > shifted
> > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > location. So
> > > > > > > it's
> > > > > > > > not the specific location that's at issue, it has to be
> > something
> > > > > > > connected
> > > > > > > > with that functionality. But we know the DSP side works fine,
> > and
> > > the
> > > > > PC
> > > > > > > > side isn't actually *doing* anything, other than writing that
> > one
> > > > > word. So
> > > > > > > > what the heck is really happening?
> > > > > > > > > > >
> > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > surrounded
> > > > > > > > with locks, and I'm not doing anything that requires grabbing
> > the
> > > > > token
> > > > > > > (the
> > > > > > > > functions for doing Gather operations do use the token, but
> > those
> > > are
> > > > > > > > commented out now).
> > > > > > > > > > >
> > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > running:
> > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > 2) A thread running the WCF server for the toolpath
> > display
> > > > > (which
> > > > > > > is
> > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> > updates
> > > > > > > > > > >
> > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > rate,
> > > > > mostly
> > > > > > > > for periodically testing the connection, and updating the
> > > "connected"
> > > > > LED
> > > > > > > in
> > > > > > > > the GUI, and showing me the GUI state through a set of
> > on-screen
> > > > > > > checkboxes.
> > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > methods
> > > > > > > are
> > > > > > > > very simple and lightweight.
> > > > > > > > > > >
> > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > that
> > > > > would
> > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> >
> >
> >
> >
>
|
|
Group: DynoMotion |
Message: 3645 |
From: himykabibble |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Whoa! Deja vu.... :-)
--- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@...> wrote:
>
> Hello Ray,
>
>
>
> I will look into your code then, as regrettably I cannot reproduce the same
> problems.
>
>
>
> -Brad Murry
>
>
>
> From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> Behalf Of himykabibble
> Sent: Monday, January 30, 2012 6:51 PM
> To: DynoMotion@yahoogroups.com
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
>
>
>
> Brad,
>
> ALL of my DSP programs are now started via invoke, and I still have the
> problem.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> "bradodarb" <bradodarb@> wrote:
> >
> > Ray,
> >
> > It is likely that my previous posts were not linked to the printf issue as
> they were a bit out of order int the timeline.
> >
> >
> > So, I was having the same problem before until I surrounded the code that
> makes calls to .c programs containing printfs with an invoke clause.
> >
> > I believe the printf unsolicited callbacks are pumping a message on a non
> STAThread, which is a big no-no on the .net side. This is just a theory, but
> forcing them to be executed in the GUI thread(via invoke) seems to resolve
> the issue.
> >
> > Let me know if that works for you as well.
> >
> > -Brad Murry
> >
> >
> > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> "himykabibble" <jagboy@> wrote:
> > >
> > > Tom,
> > >
> > > Yes, if I comment out the console message handler it behaves better. The
> message handler is doing nothing but an invoke that stuffs the passed string
> into a textbox.
> > >
> > > Things are rather worse now.... I've been exercising some of the other
> GUI controls, and I'm getting hangs galore. I seem to be able to jog and do
> MDI, even using the DSP, with no problems, but using the minor controls is
> generating tons of hangs. I'm trying to figure out why....
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> , Tom Kerekes <tk@> wrote:
> > > >
> > > > Hi Ray,
> > > > Â
> > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an
> App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP
> and may get back the unsolicited message instead of the expected response.Â
> In that case the unsolicited message received will be sent to the App via
> the ConsoleCallback and then another read will be performed to get the
> expected response.
> > > > Â
> > > > So from your description it seems like the crash is somehow being
> caused by the ConsoleCallback possibly due to a bug in the .Net interface or
> because the Console is doing something bad in your GUI. Maybe change the
> ConsoleCallback to just discard the message to help narrow things down.
> > > > Â
> > > > It isn't clear to me if the crash you report having in the MarshalPost
> is before the call or after.
> > > > Â
> > > > Regards
> > > > TK
> > > > Â
> > > > Â
> > > > Â
> > > > Â
> > > > From: himykabibble <jagboy@>
> > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > Sent: Monday, January 30, 2012 4:14 PM
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > > Â
> > > > Brad,
> > > >
> > > > As of last night, thanks to Toms suggestion to look at the DSP code,
> PCComm works, as does MDI from the DSP (and I assume most of the other
> functions, though I haven't tested them all yet). (Mind you, that same DSP
> code, printfs and all, works perfectly under KMotionCNC...) PCComm was
> "fixed" by getting rid of the printfs in the DSP code. Put the printfs back,
> and it starts locking up again (in CheckIsReady() before, but now in
> MarshalPost within WriteLineReadLine - At least it's a dead-consistent
> failure!). Console messages also work fine, as long as there are NO printfs
> in the DSP code.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote:
> > > > >
> > > > > Ray,
> > > > >
> > > > >
> > > > >
> > > > > I thought the main issue we were working on was the printf's/PComm
> issues in
> > > > > your user programs, has that situation improved at all?
> > > > >
> > > > >
> > > > >
> > > > > Good that your MDI code works though.
> > > > >
> > > > >
> > > > >
> > > > > -Brad
> > > > >
> > > > >
> > > > >
> > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > Behalf Of himykabibble
> > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
>
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Brad,
> > > > >
> > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI
> problem, but I
> > > > > still get the hangs in CheckIsRead() when I have the console
> callback
> > > > > updating the TextBox, even though it is now also being invoked.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> ,
> > > > > "bradodarb" <bradodarb@> wrote:
> > > > > >
> > > > > >
> > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed
> to
> > > > > invoke them. Kinda weird, you usually only need to invoke calls to
> your GUI
> > > > > components, but in my case an HTML button is being clicked, handled
> by
> > > > > jscript COM marshaling over to a method in my c# code. Maybe the
> printf is
> > > > > using some [STAThread ] component..
> > > > > >
> > > > > >
> > > > > > So Ray, surround your calls in an invoke clause as well and see if
> it
> > > > > improves.
> > > > > >
> > > > > > Here is a nice tidy way to do it::
> > > > > >
> > > > > > public void UpdateDocument(Action action)
> > > > > > {
> > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > {
> > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > }
> > > > > > else
> > > > > > {
> > > > > > action();
> > > > > > }
> > > > > >
> > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > >
> > > > > > UpdateDocument(new Action(delegate()
> > > > > > {
> > > > > > //Your existing code inside here
> > > > > > }
> > > > > > ));
> > > > > >
> > > > > > Let me know if this helps.
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> ,
> > > > > Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Hello Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > You should invoke it to your textbox.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > In related news, I have no issues running any of my previously
> > > > > problematic
> > > > > > > procedures inside a console app.. Only crashes my winforms
> browserapp.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> ]
> > > > > On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
>
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > I wired in the console message handler, and I now get frequent
> lock-ups.
> > > > > My
> > > > > > > handler does nothing more than one line of code that stuffs the
> String
> > > > > > > argument into a TextBox. With that one line commented out, all
> is good.
> > > > > But
> > > > > > > if I uncomment that one line, then I get frequent hangs - the
> app just
> > > > > locks
> > > > > > > up. No errors, exceptions, or anything but the GUI stops
> responding
> > > > > > > entirely. The callback does work as it should, until the app
> locks up.
> > > > > Is
> > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > Well it makes me happy to see someone besides me having
> strange things
> > > > > > > happening! :-) Hopefully when you get to the bottom of your
> problem it
> > > > > will
> > > > > > > fix mine as well.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works
> just fine,
> > > > > it
> > > > > > > only
> > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons.
> If you
> > > > > look
> > > > > > > at
> > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > commands as
> > > > > > > if
> > > > > > > > > they were any other MCode.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Still, it does not explain why it works for me and not you
> using the
> > > > > > > > > CompileAndLoadCoff.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Then again, I am not using any PComm in my test
> prog(print.c). I'll
> > > > > try
> > > > > > > > > that and get back to you.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > No, I do not have the message event hooked up in my app.
> (Actually,
> > > > > > > didn't
> > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > >
> > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > InvokeAction a
> > > > > > > > > better way to do it?
> > > > > > > > >
> > > > > > > > > I've just run into a new problem as well. Two steps forward,
> one
> > > > > > > > > backward.... MDI commands, which WERE working fine, now are
> not.
> > > > > > > Non-motion
> > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> commands
> > > > > never
> > > > > > > > > issue a Completed callback. The move IS completed, I get the
> status
> > > > > > > > > callback, then nothing. When I halt the interpreter, by
> hitting my
> > > > > > > E-stop
> > > > > > > > > button, or re-starting the App, THEN I get the completed
> callback.
> > > > > So
> > > > > > > > > something is blocking something there as well. This was
> working fine
> > > > > > > until I
> > > > > > > > > fixed the original PCComm problem.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hello Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I am wondering if there are some .net memory sharing
> issues going
> > > > > on
> > > > > > > here.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I just set one of my user buttons to fire off the print.c
> program
> > > > > and
> > > > > > > I
> > > > > > > > > get
> > > > > > > > > > the same result.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I do, and I get the Hello, World message followed by an
> immediate
> > > > > > > crash.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > It is interesting to note that we get the print messages
> just fine
> > > > > > > from
> > > > > > > > > the
> > > > > > > > > > c# console application.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So I tried this code in my button event handler as a quick
> and
> > > > > dirty
> > > > > > > > > test::
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot +
> @"\C
> > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > >
> > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > TheCFile, false));
> > > > > > > > > >
> > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > >
> > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > And I get my callbacks from the printf just fine!(no
> crashes).
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I looks like InvokeAction with printf's are doing
> something screwy
> > > > > > > here.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Ray- Are you invoking your cprogram via
> Interpreter.InvokeAction
> > > > > as
> > > > > > > well?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Tom,
> > > > > > > > > >
> > > > > > > > > > I know this is a stupid question, but is there some
> interaction or
> > > > > > > shared
> > > > > > > > > > resources between the PCComm stuff/Gather buffer and
> printfs? I
> > > > > had
> > > > > > > some
> > > > > > > > > > printfs in the Home code that I had put in while beating
> on this
> > > > > > > thing. I
> > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > changed.
> > > > > > > > > printfs
> > > > > > > > > > still do not come out in the KMotion console after I
> re-start my
> > > > > app,
> > > > > > > so
> > > > > > > > > > there is something still not completely right, but PCComm
> is now
> > > > > > > working,
> > > > > > > > > so
> > > > > > > > > > thanks for pointing me in the right direction. I just
> didn't even
> > > > > > > really
> > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > KMotionCNC....
> > > > > > > > > >
> > > > > > > > > > What could cause KMotion to be able to talk to the board
> just
> > > > > fine,
> > > > > > > but
> > > > > > > > > NOT
> > > > > > > > > > see printfs? For that matter, when in that state, it does
> not see
> > > > > DSP
> > > > > > > > > tasks
> > > > > > > > > > running either, as indficated as there are no green
> highlights on
> > > > > the
> > > > > > > task
> > > > > > > > > > IDs next to the editor window. But after re-starting
> Kmotion,
> > > > > without
> > > > > > > > > > restarting my app, all is well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Tom,
> > > > > > > > > > >
> > > > > > > > > > > The DSP code is my home function, which works perfectly
> under
> > > > > > > > > KMotionCNC.
> > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > >
> > > > > > > > > > > main()
> > > > > > > > > > > {
> > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > This gives a different result. The first printf appears
> every
> > > > > time.
> > > > > > > The
> > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > strangely in
> > > > > > > any
> > > > > > > > > > way that I can see, even if I open and close it several
> times.
> > > > > But, if
> > > > > > > I
> > > > > > > > > > open KMotion, then open my app, then close it, then
> re-open it,
> > > > > > > KMotion
> > > > > > > > > will
> > > > > > > > > > still be able to talk to the board, and execute commands
> from the
> > > > > > > console,
> > > > > > > > > > but printfs from the DSP no longer show up in the console
> window,
> > > > > > > until I
> > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > >
> > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > influencing
> > > > > > > the
> > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > wouldn't be
> > > > > > > > > doing
> > > > > > > > > > when run under KMotionCNC, where it's always works
> perfectly??
> > > > > > > > > > >
> > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > >
> > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it
> sounds
> > > > > more
> > > > > > > like a
> > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC?
> What does
> > > > > it
> > > > > > > do
> > > > > > > > > > after it sees the persist var cleared? What if you clear
> it from
> > > > > the
> > > > > > > > > KMotion
> > > > > > > > > > Console instead? Otherwise I can look at if you post all
> the code.
> > > > >
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > TK
> > > > > > > > > > > >
> > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@>
> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> suggestions
> > > > > on
> > > > > > > how
> > > > > > > > > to
> > > > > > > > > > proceed. As long as I don't touch Persist[100], everything
> works
> > > > > just
> > > > > > > > > fine.
> > > > > > > > > > I can start my app, run programs, exit, connect,
> disconnect, and
> > > > > it
> > > > > > > seems
> > > > > > > > > to
> > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my
> PCComm
> > > > > code
> > > > > > > > > > correctly processes it, and clears Persist[100], and
> shortly after
> > > > > > > that,
> > > > > > > > > the
> > > > > > > > > > board "goes missing", and I get the dialog asking me if I
> want to
> > > > > run
> > > > > > > the
> > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> VS2008,
> > > > > even
> > > > > > > > > though
> > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug"
> prompt, it
> > > > > opens
> > > > > > > > > > VS2008, loads the current source file, and that's it. No
> debugger,
> > > > > no
> > > > > > > > > > nothing. That much is, I'm sure, a configuration thing,
> due to
> > > > > having
> > > > > > > both
> > > > > > > > > > versions installed, but I not only don't know how to fix
> it, I am
> > > > > > > > > reluctant
> > > > > > > > > > to try to get 2008 working in that context, for fear it
> will screw
> > > > > up
> > > > > > > > > 2010,
> > > > > > > > > > which is what I generally use. I only installed 2008 to be
> able to
> > > > > > > build
> > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100],
> while
> > > > > not
> > > > > > > the
> > > > > > > > > > actual cause of the problem, is somehow triggering
> whatever it is
> > > > > that
> > > > > > > is
> > > > > > > > > > going wrong, but I'm totally at a loss to understand what
> is going
> > > > > > > wrong,
> > > > > > > > > or
> > > > > > > > > > how, and have had no success in trying to narrow it down.
> If I
> > > > > comment
> > > > > > > out
> > > > > > > > > > the one line that clears Persist[100] after a PCComm
> command, the
> > > > > > > problem
> > > > > > > > > > goes away entirely, and everything works perfectly. If I
> change
> > > > > that
> > > > > > > one
> > > > > > > > > > line to write *any* other location, like 99, or 101, the
> failure
> > > > > > > > > "signature"
> > > > > > > > > > changes - rather than crashing almost immediately after
> the
> > > > > Persist
> > > > > > > > > location
> > > > > > > > > > is written, the app continues to run normally until I
> close it.
> > > > > > > > > > > > >
> > > > > > > > > > > > > But, if I then re-start the app without first
> disconnecting
> > > > > and
> > > > > > > > > > reconnecting the board, I get the debug dialog again as
> soon as
> > > > > the
> > > > > > > new
> > > > > > > > > app
> > > > > > > > > > instance recognizes the connection is available, and does
> its
> > > > > > > > > KM_Controller
> > > > > > > > > > initialization. I've stepped through all the init code and
> the
> > > > > > > > > constructors
> > > > > > > > > > on that second start-up, and whatever is going wrong is
> going
> > > > > wrong
> > > > > > > AFTER
> > > > > > > > > > they have all run, and I don't know how to stop it at a
> point that
> > > > > > > would
> > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Not surprisingly, if I change the location used for
> PComm (I
> > > > > > > shifted
> > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > location. So
> > > > > > > > > it's
> > > > > > > > > > not the specific location that's at issue, it has to be
> something
> > > > > > > > > connected
> > > > > > > > > > with that functionality. But we know the DSP side works
> fine, and
> > > > > the
> > > > > > > PC
> > > > > > > > > > side isn't actually *doing* anything, other than writing
> that one
> > > > > > > word. So
> > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've double-checked and all my KM_Controller
> accesses are
> > > > > > > surrounded
> > > > > > > > > > with locks, and I'm not doing anything that requires
> grabbing the
> > > > > > > token
> > > > > > > > > (the
> > > > > > > > > > functions for doing Gather operations do use the token,
> but those
> > > > > are
> > > > > > > > > > commented out now).
> > > > > > > > > > > > >
> > > > > > > > > > > > > At the point where it's crashing, there are three
> threads
> > > > > > > running:
> > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath
> display
> > > > > > > (which
> > > > > > > > > is
> > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> updates
> > > > > > > > > > > > >
> > > > > > > > > > > > > The app thread also has one Timer running, at a
> 100mSec
> > > > > rate,
> > > > > > > mostly
> > > > > > > > > > for periodically testing the connection, and updating the
> > > > > "connected"
> > > > > > > LED
> > > > > > > > > in
> > > > > > > > > > the GUI, and showing me the GUI state through a set of
> on-screen
> > > > > > > > > checkboxes.
> > > > > > > > > > This thread is the one that calls the PCComm handler. All
> Timer
> > > > > > > methods
> > > > > > > > > are
> > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my
> code if
> > > > > that
> > > > > > > would
> > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3646 |
From: Tom Kerekes |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Hi Andrew,
Sorry this message was marked as spam and was delayed coming through.
Could you explain a bit more. Doing a printf every second or so from KFLOP to the KMotion.exe Console Screen also sometimes freezes KMotion.exe?
Regards
TK
Group: DynoMotion |
Message: 3647 |
From: himykabibble |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
What I'm seeing right now is VERY long times to do the gather in PCComm to retrieve a short String - sometimes on the order of several seconds to retrieve a String that is perhaps a dozen characters. printfs are coming through reliably, and quickly. It seems to me like most operations that are talking to the board are taking an inordinately long time to complete, slowing everything down. I have no doubts this is a threading issue, but I don't know what, and VS2010 seems to provide no support for examining threads...
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Unfortunately, my celebration turns out to be a bit premature. My deadlocks are back, after making a few minor changes.... I also noticed today while running on the machine that DRO updates are still very slow - on the order to 2-3 updates/seconds. I suspect there's a lot of waiting going on somewhere in there.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Andrew Ford <ahford@> wrote:
> >
> > I'm able to get the same hang in Kmotion with a printf every second or so.
> > I didn't take too close a look at it in the debugger but it looks like a
> > deadlock. I could take a closer look again tonight.
> >
> > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> >
> > > **
> > >
> > >
> > > Hi Ray,
> > >
> > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App
> > > does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and
> > > may get back the unsolicited message instead of the expected response. In
> > > that case the unsolicited message received will be sent to the App via the
> > > ConsoleCallback and then another read will be performed to get the expected
> > > response.
> > >
> > > So from your description it seems like the crash is somehow being caused
> > > by the ConsoleCallback possibly due to a bug in the .Net interface or
> > > because the Console is doing something bad in your GUI. Maybe change the
> > > ConsoleCallback to just discard the message to help narrow things down.
> > >
> > > It isn't clear to me if the crash you report having in the MarshalPost is
> > > before the call or after.
> > >
> > > Regards
> > > TK
> > >
> > >
> > >
> > >
> > > *From:* himykabibble <jagboy@>
> > > *To:* DynoMotion@yahoogroups.com
> > > *Sent:* Monday, January 30, 2012 4:14 PM
> > >
> > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > > Brad,
> > >
> > > As of last night, thanks to Toms suggestion to look at the DSP code,
> > > PCComm works, as does MDI from the DSP (and I assume most of the other
> > > functions, though I haven't tested them all yet). (Mind you, that same DSP
> > > code, printfs and all, works perfectly under KMotionCNC...) PCComm was
> > > "fixed" by getting rid of the printfs in the DSP code. Put the printfs
> > > back, and it starts locking up again (in CheckIsReady() before, but now in
> > > MarshalPost within WriteLineReadLine - At least it's a dead-consistent
> > > failure!). Console messages also work fine, as long as there are NO printfs
> > > in the DSP code.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > >
> > > > Ray,
> > > >
> > > >
> > > >
> > > > I thought the main issue we were working on was the printf's/PComm
> > > issues in
> > > > your user programs, has that situation improved at all?
> > > >
> > > >
> > > >
> > > > Good that your MDI code works though.
> > > >
> > > >
> > > >
> > > > -Brad
> > > >
> > > >
> > > >
> > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > Behalf Of himykabibble
> > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > To: DynoMotion@yahoogroups.com
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Brad,
> > > >
> > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem,
> > > but I
> > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > updating the TextBox, even though it is now also being invoked.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > ,
> > > > "bradodarb" <bradodarb@> wrote:
> > > > >
> > > > >
> > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > invoke them. Kinda weird, you usually only need to invoke calls to your
> > > GUI
> > > > components, but in my case an HTML button is being clicked, handled by
> > > > jscript COM marshaling over to a method in my c# code. Maybe the printf
> > > is
> > > > using some [STAThread ] component..
> > > > >
> > > > >
> > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > improves.
> > > > >
> > > > > Here is a nice tidy way to do it::
> > > > >
> > > > > public void UpdateDocument(Action action)
> > > > > {
> > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > {
> > > > > _GuiHost.Parent.Invoke(action);
> > > > > }
> > > > > else
> > > > > {
> > > > > action();
> > > > > }
> > > > >
> > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > >
> > > > > UpdateDocument(new Action(delegate()
> > > > > {
> > > > > //Your existing code inside here
> > > > > }
> > > > > ));
> > > > >
> > > > > Let me know if this helps.
> > > > >
> > > > > -Brad Murry
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > ,
> > > > Brad Murry <bradodarb@> wrote:
> > > > > >
> > > > > > Hello Ray,
> > > > > >
> > > > > >
> > > > > >
> > > > > > You should invoke it to your textbox.
> > > > > >
> > > > > >
> > > > > >
> > > > > > In related news, I have no issues running any of my previously
> > > > problematic
> > > > > > procedures inside a console app.. Only crashes my winforms
> > > browserapp.
> > > > > >
> > > > > >
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > >
> > > > > >
> > > > > > From: DynoMotion@yahoogroups.com <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > ]
> > > > On
> > > > > > Behalf Of himykabibble
> > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > >
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > I wired in the console message handler, and I now get frequent
> > > lock-ups.
> > > > My
> > > > > > handler does nothing more than one line of code that stuffs the
> > > String
> > > > > > argument into a TextBox. With that one line commented out, all is
> > > good.
> > > > But
> > > > > > if I uncomment that one line, then I get frequent hangs - the app
> > > just
> > > > locks
> > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > entirely. The callback does work as it should, until the app locks
> > > up.
> > > > Is
> > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > Well it makes me happy to see someone besides me having strange
> > > things
> > > > > > happening! :-) Hopefully when you get to the bottom of your problem
> > > it
> > > > will
> > > > > > fix mine as well.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > ,
> > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just
> > > fine,
> > > > it
> > > > > > only
> > > > > > > > crashes when I use the InvokeAction.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If
> > > you
> > > > look
> > > > > > at
> > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > commands as
> > > > > > if
> > > > > > > > they were any other MCode.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Still, it does not explain why it works for me and not you using
> > > the
> > > > > > > > CompileAndLoadCoff.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Then again, I am not using any PComm in my test prog(print.c).
> > > I'll
> > > > try
> > > > > > > > that and get back to you.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > To: DynoMotion@yahoogroups.com <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > No, I do not have the message event hooked up in my app.
> > > (Actually,
> > > > > > didn't
> > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > >
> > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > InvokeAction a
> > > > > > > > better way to do it?
> > > > > > > >
> > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > Non-motion
> > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> > > commands
> > > > never
> > > > > > > > issue a Completed callback. The move IS completed, I get the
> > > status
> > > > > > > > callback, then nothing. When I halt the interpreter, by hitting
> > > my
> > > > > > E-stop
> > > > > > > > button, or re-starting the App, THEN I get the completed
> > > callback.
> > > > So
> > > > > > > > something is blocking something there as well. This was working
> > > fine
> > > > > > until I
> > > > > > > > fixed the original PCComm problem.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Hello Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I am wondering if there are some .net memory sharing issues
> > > going
> > > > on
> > > > > > here.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I just set one of my user buttons to fire off the print.c
> > > program
> > > > and
> > > > > > I
> > > > > > > > get
> > > > > > > > > the same result.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Do you have the message event wired up? -
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I do, and I get the Hello, World message followed by an
> > > immediate
> > > > > > crash.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > It is interesting to note that we get the print messages just
> > > fine
> > > > > > from
> > > > > > > > the
> > > > > > > > > c# console application.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > dirty
> > > > > > > > test::
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > >
> > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > TheCFile, false));
> > > > > > > > >
> > > > > > > > > //Excecute the program we just loaded
> > > > > > > > >
> > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I looks like InvokeAction with printf's are doing something
> > > screwy
> > > > > > here.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Ray- Are you invoking your cprogram via
> > > Interpreter.InvokeAction
> > > > as
> > > > > > well?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Tom,
> > > > > > > > >
> > > > > > > > > I know this is a stupid question, but is there some
> > > interaction or
> > > > > > shared
> > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > had
> > > > > > some
> > > > > > > > > printfs in the Home code that I had put in while beating on
> > > this
> > > > > > thing. I
> > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > changed.
> > > > > > > > printfs
> > > > > > > > > still do not come out in the KMotion console after I re-start
> > > my
> > > > app,
> > > > > > so
> > > > > > > > > there is something still not completely right, but PCComm is
> > > now
> > > > > > working,
> > > > > > > > so
> > > > > > > > > thanks for pointing me in the right direction. I just didn't
> > > even
> > > > > > really
> > > > > > > > > consider the DSP Code, because it's always worked under
> > > > KMotionCNC....
> > > > > > > > >
> > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > fine,
> > > > > > but
> > > > > > > > NOT
> > > > > > > > > see printfs? For that matter, when in that state, it does not
> > > see
> > > > DSP
> > > > > > > > tasks
> > > > > > > > > running either, as indficated as there are no green highlights
> > > on
> > > > the
> > > > > > task
> > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > without
> > > > > > > > > restarting my app, all is well.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > Tom,
> > > > > > > > > >
> > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > KMotionCNC.
> > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > >
> > > > > > > > > > main()
> > > > > > > > > > {
> > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > This gives a different result. The first printf appears every
> > > > time.
> > > > > > The
> > > > > > > > > second one never appears. My app does not crash or behave
> > > > strangely in
> > > > > > any
> > > > > > > > > way that I can see, even if I open and close it several times.
> > > > But, if
> > > > > > I
> > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > KMotion
> > > > > > > > will
> > > > > > > > > still be able to talk to the board, and execute commands from
> > > the
> > > > > > console,
> > > > > > > > > but printfs from the DSP no longer show up in the console
> > > window,
> > > > > > until I
> > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > >
> > > > > > > > > > I will try to narrow down what in the Home program is
> > > > influencing
> > > > > > the
> > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > wouldn't be
> > > > > > > > doing
> > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > >
> > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hi Ray,
> > > > > > > > > > >
> > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > more
> > > > > > like a
> > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What
> > > does
> > > > it
> > > > > > do
> > > > > > > > > after it sees the persist var cleared? What if you clear it
> > > from
> > > > the
> > > > > > > > KMotion
> > > > > > > > > Console instead? Otherwise I can look at if you post all the
> > > code.
> > > >
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > TK
> > > > > > > > > > >
> > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@>
> > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> > > suggestions
> > > > on
> > > > > > how
> > > > > > > > to
> > > > > > > > > proceed. As long as I don't touch Persist[100], everything
> > > works
> > > > just
> > > > > > > > fine.
> > > > > > > > > I can start my app, run programs, exit, connect, disconnect,
> > > and
> > > > it
> > > > > > seems
> > > > > > > > to
> > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my
> > > PCComm
> > > > code
> > > > > > > > > correctly processes it, and clears Persist[100], and shortly
> > > after
> > > > > > that,
> > > > > > > > the
> > > > > > > > > board "goes missing", and I get the dialog asking me if I want
> > > to
> > > > run
> > > > > > the
> > > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> > > VS2008,
> > > > even
> > > > > > > > though
> > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt,
> > > it
> > > > opens
> > > > > > > > > VS2008, loads the current source file, and that's it. No
> > > debugger,
> > > > no
> > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > having
> > > > > > both
> > > > > > > > > versions installed, but I not only don't know how to fix it, I
> > > am
> > > > > > > > reluctant
> > > > > > > > > to try to get 2008 working in that context, for fear it will
> > > screw
> > > > up
> > > > > > > > 2010,
> > > > > > > > > which is what I generally use. I only installed 2008 to be
> > > able to
> > > > > > build
> > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > >
> > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > not
> > > > > > the
> > > > > > > > > actual cause of the problem, is somehow triggering whatever it
> > > is
> > > > that
> > > > > > is
> > > > > > > > > going wrong, but I'm totally at a loss to understand what is
> > > going
> > > > > > wrong,
> > > > > > > > or
> > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > comment
> > > > > > out
> > > > > > > > > the one line that clears Persist[100] after a PCComm command,
> > > the
> > > > > > problem
> > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > that
> > > > > > one
> > > > > > > > > line to write *any* other location, like 99, or 101, the
> > > failure
> > > > > > > > "signature"
> > > > > > > > > changes - rather than crashing almost immediately after the
> > > > Persist
> > > > > > > > location
> > > > > > > > > is written, the app continues to run normally until I close
> > > it.
> > > > > > > > > > > >
> > > > > > > > > > > > But, if I then re-start the app without first
> > > disconnecting
> > > > and
> > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > the
> > > > > > new
> > > > > > > > app
> > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > KM_Controller
> > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > constructors
> > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > wrong
> > > > > > AFTER
> > > > > > > > > they have all run, and I don't know how to stop it at a point
> > > that
> > > > > > would
> > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > >
> > > > > > > > > > > > Not surprisingly, if I change the location used for
> > > PComm (I
> > > > > > shifted
> > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > location. So
> > > > > > > > it's
> > > > > > > > > not the specific location that's at issue, it has to be
> > > something
> > > > > > > > connected
> > > > > > > > > with that functionality. But we know the DSP side works fine,
> > > and
> > > > the
> > > > > > PC
> > > > > > > > > side isn't actually *doing* anything, other than writing that
> > > one
> > > > > > word. So
> > > > > > > > > what the heck is really happening?
> > > > > > > > > > > >
> > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > surrounded
> > > > > > > > > with locks, and I'm not doing anything that requires grabbing
> > > the
> > > > > > token
> > > > > > > > (the
> > > > > > > > > functions for doing Gather operations do use the token, but
> > > those
> > > > are
> > > > > > > > > commented out now).
> > > > > > > > > > > >
> > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > running:
> > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > 2) A thread running the WCF server for the toolpath
> > > display
> > > > > > (which
> > > > > > > > is
> > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> > > updates
> > > > > > > > > > > >
> > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > rate,
> > > > > > mostly
> > > > > > > > > for periodically testing the connection, and updating the
> > > > "connected"
> > > > > > LED
> > > > > > > > in
> > > > > > > > > the GUI, and showing me the GUI state through a set of
> > > on-screen
> > > > > > > > checkboxes.
> > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > methods
> > > > > > > > are
> > > > > > > > > very simple and lightweight.
> > > > > > > > > > > >
> > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > that
> > > > > > would
> > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3648 |
From: himykabibble |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Tom/Brad,
Earlier I was again seeing hangs associated with PCComm and/or Console messages. I added a message queue for the console messages, and it seems to be working solidly again, albeit slow. The GUI will sometimes become unresponsive for several seconds (up to 15 at times), then come back to life. Even when it's working, it seems sluggish to me. As I mentioned, the DROs seem to be updating only about 2-3 times per second. If I run a DSP program that does a printf every 2000 time slices, the messages come out at irregular intervals. If I send the messages through PCComm, both the average time, and the irregularity are much greater, with the bulk of time being spent doing the String gathers, which sometimes take as much as 2 or 3 seconds to complete, for a message that is only about a dozen characters. I have to assume I still have some blocking problems. Any suggestions how to find them?
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> What I'm seeing right now is VERY long times to do the gather in PCComm to retrieve a short String - sometimes on the order of several seconds to retrieve a String that is perhaps a dozen characters. printfs are coming through reliably, and quickly. It seems to me like most operations that are talking to the board are taking an inordinately long time to complete, slowing everything down. I have no doubts this is a threading issue, but I don't know what, and VS2010 seems to provide no support for examining threads...
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> >
> > Unfortunately, my celebration turns out to be a bit premature. My deadlocks are back, after making a few minor changes.... I also noticed today while running on the machine that DRO updates are still very slow - on the order to 2-3 updates/seconds. I suspect there's a lot of waiting going on somewhere in there.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Andrew Ford <ahford@> wrote:
> > >
> > > I'm able to get the same hang in Kmotion with a printf every second or so.
> > > I didn't take too close a look at it in the debugger but it looks like a
> > > deadlock. I could take a closer look again tonight.
> > >
> > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> > >
> > > > **
> > > >
> > > >
> > > > Hi Ray,
> > > >
> > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App
> > > > does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and
> > > > may get back the unsolicited message instead of the expected response. In
> > > > that case the unsolicited message received will be sent to the App via the
> > > > ConsoleCallback and then another read will be performed to get the expected
> > > > response.
> > > >
> > > > So from your description it seems like the crash is somehow being caused
> > > > by the ConsoleCallback possibly due to a bug in the .Net interface or
> > > > because the Console is doing something bad in your GUI. Maybe change the
> > > > ConsoleCallback to just discard the message to help narrow things down.
> > > >
> > > > It isn't clear to me if the crash you report having in the MarshalPost is
> > > > before the call or after.
> > > >
> > > > Regards
> > > > TK
> > > >
> > > >
> > > >
> > > >
> > > > *From:* himykabibble <jagboy@>
> > > > *To:* DynoMotion@yahoogroups.com
> > > > *Sent:* Monday, January 30, 2012 4:14 PM
> > > >
> > > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > > Brad,
> > > >
> > > > As of last night, thanks to Toms suggestion to look at the DSP code,
> > > > PCComm works, as does MDI from the DSP (and I assume most of the other
> > > > functions, though I haven't tested them all yet). (Mind you, that same DSP
> > > > code, printfs and all, works perfectly under KMotionCNC...) PCComm was
> > > > "fixed" by getting rid of the printfs in the DSP code. Put the printfs
> > > > back, and it starts locking up again (in CheckIsReady() before, but now in
> > > > MarshalPost within WriteLineReadLine - At least it's a dead-consistent
> > > > failure!). Console messages also work fine, as long as there are NO printfs
> > > > in the DSP code.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > > >
> > > > > Ray,
> > > > >
> > > > >
> > > > >
> > > > > I thought the main issue we were working on was the printf's/PComm
> > > > issues in
> > > > > your user programs, has that situation improved at all?
> > > > >
> > > > >
> > > > >
> > > > > Good that your MDI code works though.
> > > > >
> > > > >
> > > > >
> > > > > -Brad
> > > > >
> > > > >
> > > > >
> > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > > Behalf Of himykabibble
> > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > To: DynoMotion@yahoogroups.com
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Brad,
> > > > >
> > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem,
> > > > but I
> > > > > still get the hangs in CheckIsRead() when I have the console callback
> > > > > updating the TextBox, even though it is now also being invoked.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > ,
> > > > > "bradodarb" <bradodarb@> wrote:
> > > > > >
> > > > > >
> > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to
> > > > > invoke them. Kinda weird, you usually only need to invoke calls to your
> > > > GUI
> > > > > components, but in my case an HTML button is being clicked, handled by
> > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf
> > > > is
> > > > > using some [STAThread ] component..
> > > > > >
> > > > > >
> > > > > > So Ray, surround your calls in an invoke clause as well and see if it
> > > > > improves.
> > > > > >
> > > > > > Here is a nice tidy way to do it::
> > > > > >
> > > > > > public void UpdateDocument(Action action)
> > > > > > {
> > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > {
> > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > }
> > > > > > else
> > > > > > {
> > > > > > action();
> > > > > > }
> > > > > >
> > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > >
> > > > > > UpdateDocument(new Action(delegate()
> > > > > > {
> > > > > > //Your existing code inside here
> > > > > > }
> > > > > > ));
> > > > > >
> > > > > > Let me know if this helps.
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > ,
> > > > > Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Hello Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > You should invoke it to your textbox.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > In related news, I have no issues running any of my previously
> > > > > problematic
> > > > > > > procedures inside a console app.. Only crashes my winforms
> > > > browserapp.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > ]
> > > > > On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > >
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > I wired in the console message handler, and I now get frequent
> > > > lock-ups.
> > > > > My
> > > > > > > handler does nothing more than one line of code that stuffs the
> > > > String
> > > > > > > argument into a TextBox. With that one line commented out, all is
> > > > good.
> > > > > But
> > > > > > > if I uncomment that one line, then I get frequent hangs - the app
> > > > just
> > > > > locks
> > > > > > > up. No errors, exceptions, or anything but the GUI stops responding
> > > > > > > entirely. The callback does work as it should, until the app locks
> > > > up.
> > > > > Is
> > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > Well it makes me happy to see someone besides me having strange
> > > > things
> > > > > > > happening! :-) Hopefully when you get to the bottom of your problem
> > > > it
> > > > > will
> > > > > > > fix mine as well.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just
> > > > fine,
> > > > > it
> > > > > > > only
> > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If
> > > > you
> > > > > look
> > > > > > > at
> > > > > > > > > the Ccode, it populates the MCodeActions as fires the button
> > > > > commands as
> > > > > > > if
> > > > > > > > > they were any other MCode.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Still, it does not explain why it works for me and not you using
> > > > the
> > > > > > > > > CompileAndLoadCoff.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Then again, I am not using any PComm in my test prog(print.c).
> > > > I'll
> > > > > try
> > > > > > > > > that and get back to you.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > No, I do not have the message event hooked up in my app.
> > > > (Actually,
> > > > > > > didn't
> > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > >
> > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > InvokeAction a
> > > > > > > > > better way to do it?
> > > > > > > > >
> > > > > > > > > I've just run into a new problem as well. Two steps forward, one
> > > > > > > > > backward.... MDI commands, which WERE working fine, now are not.
> > > > > > > Non-motion
> > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> > > > commands
> > > > > never
> > > > > > > > > issue a Completed callback. The move IS completed, I get the
> > > > status
> > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting
> > > > my
> > > > > > > E-stop
> > > > > > > > > button, or re-starting the App, THEN I get the completed
> > > > callback.
> > > > > So
> > > > > > > > > something is blocking something there as well. This was working
> > > > fine
> > > > > > > until I
> > > > > > > > > fixed the original PCComm problem.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hello Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I am wondering if there are some .net memory sharing issues
> > > > going
> > > > > on
> > > > > > > here.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I just set one of my user buttons to fire off the print.c
> > > > program
> > > > > and
> > > > > > > I
> > > > > > > > > get
> > > > > > > > > > the same result.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I do, and I get the Hello, World message followed by an
> > > > immediate
> > > > > > > crash.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > It is interesting to note that we get the print messages just
> > > > fine
> > > > > > > from
> > > > > > > > > the
> > > > > > > > > > c# console application.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So I tried this code in my button event handler as a quick and
> > > > > dirty
> > > > > > > > > test::
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C
> > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > >
> > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > TheCFile, false));
> > > > > > > > > >
> > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > >
> > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes).
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I looks like InvokeAction with printf's are doing something
> > > > screwy
> > > > > > > here.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Ray- Are you invoking your cprogram via
> > > > Interpreter.InvokeAction
> > > > > as
> > > > > > > well?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Tom,
> > > > > > > > > >
> > > > > > > > > > I know this is a stupid question, but is there some
> > > > interaction or
> > > > > > > shared
> > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I
> > > > > had
> > > > > > > some
> > > > > > > > > > printfs in the Home code that I had put in while beating on
> > > > this
> > > > > > > thing. I
> > > > > > > > > > just took them out, and it's now working. Nothing else has
> > > > > changed.
> > > > > > > > > printfs
> > > > > > > > > > still do not come out in the KMotion console after I re-start
> > > > my
> > > > > app,
> > > > > > > so
> > > > > > > > > > there is something still not completely right, but PCComm is
> > > > now
> > > > > > > working,
> > > > > > > > > so
> > > > > > > > > > thanks for pointing me in the right direction. I just didn't
> > > > even
> > > > > > > really
> > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > KMotionCNC....
> > > > > > > > > >
> > > > > > > > > > What could cause KMotion to be able to talk to the board just
> > > > > fine,
> > > > > > > but
> > > > > > > > > NOT
> > > > > > > > > > see printfs? For that matter, when in that state, it does not
> > > > see
> > > > > DSP
> > > > > > > > > tasks
> > > > > > > > > > running either, as indficated as there are no green highlights
> > > > on
> > > > > the
> > > > > > > task
> > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion,
> > > > > without
> > > > > > > > > > restarting my app, all is well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Tom,
> > > > > > > > > > >
> > > > > > > > > > > The DSP code is my home function, which works perfectly under
> > > > > > > > > KMotionCNC.
> > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > >
> > > > > > > > > > > main()
> > > > > > > > > > > {
> > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > This gives a different result. The first printf appears every
> > > > > time.
> > > > > > > The
> > > > > > > > > > second one never appears. My app does not crash or behave
> > > > > strangely in
> > > > > > > any
> > > > > > > > > > way that I can see, even if I open and close it several times.
> > > > > But, if
> > > > > > > I
> > > > > > > > > > open KMotion, then open my app, then close it, then re-open it,
> > > > > > > KMotion
> > > > > > > > > will
> > > > > > > > > > still be able to talk to the board, and execute commands from
> > > > the
> > > > > > > console,
> > > > > > > > > > but printfs from the DSP no longer show up in the console
> > > > window,
> > > > > > > until I
> > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > >
> > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > influencing
> > > > > > > the
> > > > > > > > > > PCComm stuff. But what could that program be doing that it
> > > > > wouldn't be
> > > > > > > > > doing
> > > > > > > > > > when run under KMotionCNC, where it's always works perfectly??
> > > > > > > > > > >
> > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > >
> > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds
> > > > > more
> > > > > > > like a
> > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What
> > > > does
> > > > > it
> > > > > > > do
> > > > > > > > > > after it sees the persist var cleared? What if you clear it
> > > > from
> > > > > the
> > > > > > > > > KMotion
> > > > > > > > > > Console instead? Otherwise I can look at if you post all the
> > > > code.
> > > > >
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > TK
> > > > > > > > > > > >
> > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@>
> > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> > > > suggestions
> > > > > on
> > > > > > > how
> > > > > > > > > to
> > > > > > > > > > proceed. As long as I don't touch Persist[100], everything
> > > > works
> > > > > just
> > > > > > > > > fine.
> > > > > > > > > > I can start my app, run programs, exit, connect, disconnect,
> > > > and
> > > > > it
> > > > > > > seems
> > > > > > > > > to
> > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my
> > > > PCComm
> > > > > code
> > > > > > > > > > correctly processes it, and clears Persist[100], and shortly
> > > > after
> > > > > > > that,
> > > > > > > > > the
> > > > > > > > > > board "goes missing", and I get the dialog asking me if I want
> > > > to
> > > > > run
> > > > > > > the
> > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> > > > VS2008,
> > > > > even
> > > > > > > > > though
> > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt,
> > > > it
> > > > > opens
> > > > > > > > > > VS2008, loads the current source file, and that's it. No
> > > > debugger,
> > > > > no
> > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to
> > > > > having
> > > > > > > both
> > > > > > > > > > versions installed, but I not only don't know how to fix it, I
> > > > am
> > > > > > > > > reluctant
> > > > > > > > > > to try to get 2008 working in that context, for fear it will
> > > > screw
> > > > > up
> > > > > > > > > 2010,
> > > > > > > > > > which is what I generally use. I only installed 2008 to be
> > > > able to
> > > > > > > build
> > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while
> > > > > not
> > > > > > > the
> > > > > > > > > > actual cause of the problem, is somehow triggering whatever it
> > > > is
> > > > > that
> > > > > > > is
> > > > > > > > > > going wrong, but I'm totally at a loss to understand what is
> > > > going
> > > > > > > wrong,
> > > > > > > > > or
> > > > > > > > > > how, and have had no success in trying to narrow it down. If I
> > > > > comment
> > > > > > > out
> > > > > > > > > > the one line that clears Persist[100] after a PCComm command,
> > > > the
> > > > > > > problem
> > > > > > > > > > goes away entirely, and everything works perfectly. If I change
> > > > > that
> > > > > > > one
> > > > > > > > > > line to write *any* other location, like 99, or 101, the
> > > > failure
> > > > > > > > > "signature"
> > > > > > > > > > changes - rather than crashing almost immediately after the
> > > > > Persist
> > > > > > > > > location
> > > > > > > > > > is written, the app continues to run normally until I close
> > > > it.
> > > > > > > > > > > > >
> > > > > > > > > > > > > But, if I then re-start the app without first
> > > > disconnecting
> > > > > and
> > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as
> > > > > the
> > > > > > > new
> > > > > > > > > app
> > > > > > > > > > instance recognizes the connection is available, and does its
> > > > > > > > > KM_Controller
> > > > > > > > > > initialization. I've stepped through all the init code and the
> > > > > > > > > constructors
> > > > > > > > > > on that second start-up, and whatever is going wrong is going
> > > > > wrong
> > > > > > > AFTER
> > > > > > > > > > they have all run, and I don't know how to stop it at a point
> > > > that
> > > > > > > would
> > > > > > > > > > give me any useful information about what is going wrong.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Not surprisingly, if I change the location used for
> > > > PComm (I
> > > > > > > shifted
> > > > > > > > > > it from Var 100 to 80), the problem follows it to the new
> > > > > location. So
> > > > > > > > > it's
> > > > > > > > > > not the specific location that's at issue, it has to be
> > > > something
> > > > > > > > > connected
> > > > > > > > > > with that functionality. But we know the DSP side works fine,
> > > > and
> > > > > the
> > > > > > > PC
> > > > > > > > > > side isn't actually *doing* anything, other than writing that
> > > > one
> > > > > > > word. So
> > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are
> > > > > > > surrounded
> > > > > > > > > > with locks, and I'm not doing anything that requires grabbing
> > > > the
> > > > > > > token
> > > > > > > > > (the
> > > > > > > > > > functions for doing Gather operations do use the token, but
> > > > those
> > > > > are
> > > > > > > > > > commented out now).
> > > > > > > > > > > > >
> > > > > > > > > > > > > At the point where it's crashing, there are three threads
> > > > > > > running:
> > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath
> > > > display
> > > > > > > (which
> > > > > > > > > is
> > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> > > > updates
> > > > > > > > > > > > >
> > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec
> > > > > rate,
> > > > > > > mostly
> > > > > > > > > > for periodically testing the connection, and updating the
> > > > > "connected"
> > > > > > > LED
> > > > > > > > > in
> > > > > > > > > > the GUI, and showing me the GUI state through a set of
> > > > on-screen
> > > > > > > > > checkboxes.
> > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer
> > > > > > > methods
> > > > > > > > > are
> > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if
> > > > > that
> > > > > > > would
> > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3649 |
From: Brad Murry |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
ServiceConsole was not fully implemented, I wonder if that message pump is getting clogged. It is now implemented, as I saw it was being used in KMotionCNC. Not sure if that is a/the issue though. -Brad Murry From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On Behalf Of himykabibble Sent: Tuesday, January 31, 2012 10:00 PM To: DynoMotion@yahoogroups.com Subject: [DynoMotion] Re: Need Some Ideas.... Tom/Brad,
Earlier I was again seeing hangs associated with PCComm and/or Console messages. I added a message queue for the console messages, and it seems to be working solidly again, albeit slow. The GUI will sometimes become unresponsive for several seconds (up to 15 at times), then come back to life. Even when it's working, it seems sluggish to me. As I mentioned, the DROs seem to be updating only about 2-3 times per second. If I run a DSP program that does a printf every 2000 time slices, the messages come out at irregular intervals. If I send the messages through PCComm, both the average time, and the irregularity are much greater, with the bulk of time being spent doing the String gathers, which sometimes take as much as 2 or 3 seconds to complete, for a message that is only about a dozen characters. I have to assume I still have some blocking problems. Any suggestions how to find them?
Regards, Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote: > > What I'm seeing right now is VERY long times to do the gather in PCComm to retrieve a short String - sometimes on the order of several seconds to retrieve a String that is perhaps a dozen characters. printfs are coming through reliably, and quickly. It seems to me like most operations that are talking to the board are taking an inordinately long time to complete, slowing everything down. I have no doubts this is a threading issue, but I don't know what, and VS2010 seems to provide no support for examining threads... > > Regards, > Ray L. > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote: > > > > Unfortunately, my celebration turns out to be a bit premature. My deadlocks are back, after making a few minor changes.... I also noticed today while running on the machine that DRO updates are still very slow - on the order to 2-3 updates/seconds. I suspect there's a lot of waiting going on somewhere in there. > > > > Regards, > > Ray L. > > > > --- In DynoMotion@yahoogroups.com, Andrew Ford <ahford@> wrote: > > > > > > I'm able to get the same hang in Kmotion with a printf every second or so. > > > I didn't take too close a look at it in the debugger but it looks like a > > > deadlock. I could take a closer look again tonight. > > > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote: > > > > > > > ** > > > > > > > > > > > > Hi Ray, > > > > > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an App > > > > does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and > > > > may get back the unsolicited message instead of the expected response. In > > > > that case the unsolicited message received will be sent to the App via the > > > > ConsoleCallback and then another read will be performed to get the expected > > > > response. > > > > > > > > So from your description it seems like the crash is somehow being caused > > > > by the ConsoleCallback possibly due to a bug in the .Net interface or > > > > because the Console is doing something bad in your GUI. Maybe change the > > > > ConsoleCallback to just discard the message to help narrow things down. > > > > > > > > It isn't clear to me if the crash you report having in the MarshalPost is > > > > before the call or after. > > > > > > > > Regards > > > > TK > > > > > > > > > > > > > > > > > > > > *From:* himykabibble <jagboy@> > > > > *To:* DynoMotion@yahoogroups.com > > > > *Sent:* Monday, January 30, 2012 4:14 PM > > > > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > Brad, > > > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, > > > > PCComm works, as does MDI from the DSP (and I assume most of the other > > > > functions, though I haven't tested them all yet). (Mind you, that same DSP > > > > code, printfs and all, works perfectly under KMotionCNC...) PCComm was > > > > "fixed" by getting rid of the printfs in the DSP code. Put the printfs > > > > back, and it starts locking up again (in CheckIsReady() before, but now in > > > > MarshalPost within WriteLineReadLine - At least it's a dead-consistent > > > > failure!). Console messages also work fine, as long as there are NO printfs > > > > in the DSP code. > > > > > > > > Regards, > > > > Ray L. > > > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote: > > > > > > > > > > Ray, > > > > > > > > > > > > > > > > > > > > I thought the main issue we were working on was the printf's/PComm > > > > issues in > > > > > your user programs, has that situation improved at all? > > > > > > > > > > > > > > > > > > > > Good that your MDI code works though. > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On > > > > > Behalf Of himykabibble > > > > > Sent: Monday, January 30, 2012 11:24 AM > > > > > To: DynoMotion@yahoogroups.com > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, > > > > but I > > > > > still get the hangs in CheckIsRead() when I have the console callback > > > > > updating the TextBox, even though it is now also being invoked. > > > > > > > > > > Regards, > > > > > Ray L. > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > , > > > > > "bradodarb" <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to > > > > > invoke them. Kinda weird, you usually only need to invoke calls to your > > > > GUI > > > > > components, but in my case an HTML button is being clicked, handled by > > > > > jscript COM marshaling over to a method in my c# code. Maybe the printf > > > > is > > > > > using some [STAThread ] component.. > > > > > > > > > > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see if it > > > > > improves. > > > > > > > > > > > > Here is a nice tidy way to do it:: > > > > > > > > > > > > public void UpdateDocument(Action action) > > > > > > { > > > > > > if (_GuiHost.Parent.InvokeRequired) > > > > > > { > > > > > > _GuiHost.Parent.Invoke(action); > > > > > > } > > > > > > else > > > > > > { > > > > > > action(); > > > > > > } > > > > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. :: > > > > > > > > > > > > UpdateDocument(new Action(delegate() > > > > > > { > > > > > > //Your existing code inside here > > > > > > } > > > > > > )); > > > > > > > > > > > > Let me know if this helps. > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > , > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > You should invoke it to your textbox. > > > > > > > > > > > > > > > > > > > > > > > > > > > > In related news, I have no issues running any of my previously > > > > > problematic > > > > > > > procedures inside a console app.. Only crashes my winforms > > > > browserapp. > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > ] > > > > > On > > > > > > > Behalf Of himykabibble > > > > > > > Sent: Monday, January 30, 2012 10:18 AM > > > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > I wired in the console message handler, and I now get frequent > > > > lock-ups. > > > > > My > > > > > > > handler does nothing more than one line of code that stuffs the > > > > String > > > > > > > argument into a TextBox. With that one line commented out, all is > > > > good. > > > > > But > > > > > > > if I uncomment that one line, then I get frequent hangs - the app > > > > just > > > > > locks > > > > > > > up. No errors, exceptions, or anything but the GUI stops responding > > > > > > > entirely. The callback does work as it should, until the app locks > > > > up. > > > > > Is > > > > > > > this a threading thing? Nobody else writes to that TextBox. > > > > > > > > > > > > > > Regards, > > > > > > > Ray L. > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > Well it makes me happy to see someone besides me having strange > > > > things > > > > > > > happening! :-) Hopefully when you get to the bottom of your problem > > > > it > > > > > will > > > > > > > fix mine as well. > > > > > > > > > > > > > > > > Regards, > > > > > > > > Ray L. > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > , > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just > > > > fine, > > > > > it > > > > > > > only > > > > > > > > > crashes when I use the InvokeAction. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If > > > > you > > > > > look > > > > > > > at > > > > > > > > > the Ccode, it populates the MCodeActions as fires the button > > > > > commands as > > > > > > > if > > > > > > > > > they were any other MCode. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Still, it does not explain why it works for me and not you using > > > > the > > > > > > > > > CompileAndLoadCoff. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). > > > > I'll > > > > > try > > > > > > > > > that and get back to you. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > > > [mailto:DynoMotion@yahoogroups.com <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > > On > > > > > > > > > Behalf Of himykabibble > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM > > > > > > > > > To: DynoMotion@yahoogroups.com <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > No, I do not have the message event hooked up in my app. > > > > (Actually, > > > > > > > didn't > > > > > > > > > even know how to, but now I do! Cool!). > > > > > > > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is > > > > > InvokeAction a > > > > > > > > > better way to do it? > > > > > > > > > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one > > > > > > > > > backward.... MDI commands, which WERE working fine, now are not. > > > > > > > Non-motion > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion > > > > commands > > > > > never > > > > > > > > > issue a Completed callback. The move IS completed, I get the > > > > status > > > > > > > > > callback, then nothing. When I halt the interpreter, by hitting > > > > my > > > > > > > E-stop > > > > > > > > > button, or re-starting the App, THEN I get the completed > > > > callback. > > > > > So > > > > > > > > > something is blocking something there as well. This was working > > > > fine > > > > > > > until I > > > > > > > > > fixed the original PCComm problem. > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues > > > > going > > > > > on > > > > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c > > > > program > > > > > and > > > > > > > I > > > > > > > > > get > > > > > > > > > > the same result. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Do you have the message event wired up? - > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _Controller.MessageUpdated += new > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an > > > > immediate > > > > > > > crash. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > It is interesting to note that we get the print messages just > > > > fine > > > > > > > from > > > > > > > > > the > > > > > > > > > > c# console application. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and > > > > > dirty > > > > > > > > > test:: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C > > > > > > > > > > Programs\KMotionCNC\print.c"; > > > > > > > > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1, > > > > > > > > > > TheCFile, false)); > > > > > > > > > > > > > > > > > > > > //Excecute the program we just loaded > > > > > > > > > > > > > > > > > > > > _Controller.WriteLine("Execute1"); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something > > > > screwy > > > > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via > > > > Interpreter.InvokeAction > > > > > as > > > > > > > well? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > > > > On > > > > > > > > > > Behalf Of himykabibble > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM > > > > > > > > > > To: DynoMotion@yahoogroups.com > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > DynoMotion%40yahoogroups.com> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > > > > > > > I know this is a stupid question, but is there some > > > > interaction or > > > > > > > shared > > > > > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I > > > > > had > > > > > > > some > > > > > > > > > > printfs in the Home code that I had put in while beating on > > > > this > > > > > > > thing. I > > > > > > > > > > just took them out, and it's now working. Nothing else has > > > > > changed. > > > > > > > > > printfs > > > > > > > > > > still do not come out in the KMotion console after I re-start > > > > my > > > > > app, > > > > > > > so > > > > > > > > > > there is something still not completely right, but PCComm is > > > > now > > > > > > > working, > > > > > > > > > so > > > > > > > > > > thanks for pointing me in the right direction. I just didn't > > > > even > > > > > > > really > > > > > > > > > > consider the DSP Code, because it's always worked under > > > > > KMotionCNC.... > > > > > > > > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just > > > > > fine, > > > > > > > but > > > > > > > > > NOT > > > > > > > > > > see printfs? For that matter, when in that state, it does not > > > > see > > > > > DSP > > > > > > > > > tasks > > > > > > > > > > running either, as indficated as there are no green highlights > > > > on > > > > > the > > > > > > > task > > > > > > > > > > IDs next to the editor window. But after re-starting Kmotion, > > > > > without > > > > > > > > > > restarting my app, all is well. > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under > > > > > > > > > KMotionCNC. > > > > > > > > > > But, just to be sure, I went to a three line program: > > > > > > > > > > > > > > > > > > > > > > main() > > > > > > > > > > > { > > > > > > > > > > > printf("Doing MsgBox\n"); > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK); > > > > > > > > > > > printf("MsgBox Done\n"); > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > This gives a different result. The first printf appears every > > > > > time. > > > > > > > The > > > > > > > > > > second one never appears. My app does not crash or behave > > > > > strangely in > > > > > > > any > > > > > > > > > > way that I can see, even if I open and close it several times. > > > > > But, if > > > > > > > I > > > > > > > > > > open KMotion, then open my app, then close it, then re-open it, > > > > > > > KMotion > > > > > > > > > will > > > > > > > > > > still be able to talk to the board, and execute commands from > > > > the > > > > > > > console, > > > > > > > > > > but printfs from the DSP no longer show up in the console > > > > window, > > > > > > > until I > > > > > > > > > > close then re-open KMotion. Does that make any sense? > > > > > > > > > > > > > > > > > > > > > > I will try to narrow down what in the Home program is > > > > > influencing > > > > > > > the > > > > > > > > > > PCComm stuff. But what could that program be doing that it > > > > > wouldn't be > > > > > > > > > doing > > > > > > > > > > when run under KMotionCNC, where it's always works perfectly?? > > > > > > > > > > > > > > > > > > > > > > I'll post the code tomorrow. > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > > TK <tk@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > Hi Ray, > > > > > > > > > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds > > > > > more > > > > > > > like a > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What > > > > does > > > > > it > > > > > > > do > > > > > > > > > > after it sees the persist var cleared? What if you clear it > > > > from > > > > > the > > > > > > > > > KMotion > > > > > > > > > > Console instead? Otherwise I can look at if you post all the > > > > code. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > TK > > > > > > > > > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > Tom/Brad, > > > > > > > > > > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some > > > > suggestions > > > > > on > > > > > > > how > > > > > > > > > to > > > > > > > > > > proceed. As long as I don't touch Persist[100], everything > > > > works > > > > > just > > > > > > > > > fine. > > > > > > > > > > I can start my app, run programs, exit, connect, disconnect, > > > > and > > > > > it > > > > > > > seems > > > > > > > > > to > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side, my > > > > PCComm > > > > > code > > > > > > > > > > correctly processes it, and clears Persist[100], and shortly > > > > after > > > > > > > that, > > > > > > > > > the > > > > > > > > > > board "goes missing", and I get the dialog asking me if I want > > > > to > > > > > run > > > > > > > the > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is > > > > VS2008, > > > > > even > > > > > > > > > though > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, > > > > it > > > > > opens > > > > > > > > > > VS2008, loads the current source file, and that's it. No > > > > debugger, > > > > > no > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing, due to > > > > > having > > > > > > > both > > > > > > > > > > versions installed, but I not only don't know how to fix it, I > > > > am > > > > > > > > > reluctant > > > > > > > > > > to try to get 2008 working in that context, for fear it will > > > > screw > > > > > up > > > > > > > > > 2010, > > > > > > > > > > which is what I generally use. I only installed 2008 to be > > > > able to > > > > > > > build > > > > > > > > > > KMotion, and otherwise don't use it. > > > > > > > > > > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while > > > > > not > > > > > > > the > > > > > > > > > > actual cause of the problem, is somehow triggering whatever it > > > > is > > > > > that > > > > > > > is > > > > > > > > > > going wrong, but I'm totally at a loss to understand what is > > > > going > > > > > > > wrong, > > > > > > > > > or > > > > > > > > > > how, and have had no success in trying to narrow it down. If I > > > > > comment > > > > > > > out > > > > > > > > > > the one line that clears Persist[100] after a PCComm command, > > > > the > > > > > > > problem > > > > > > > > > > goes away entirely, and everything works perfectly. If I change > > > > > that > > > > > > > one > > > > > > > > > > line to write *any* other location, like 99, or 101, the > > > > failure > > > > > > > > > "signature" > > > > > > > > > > changes - rather than crashing almost immediately after the > > > > > Persist > > > > > > > > > location > > > > > > > > > > is written, the app continues to run normally until I close > > > > it. > > > > > > > > > > > > > > > > > > > > > > > > > > But, if I then re-start the app without first > > > > disconnecting > > > > > and > > > > > > > > > > reconnecting the board, I get the debug dialog again as soon as > > > > > the > > > > > > > new > > > > > > > > > app > > > > > > > > > > instance recognizes the connection is available, and does its > > > > > > > > > KM_Controller > > > > > > > > > > initialization. I've stepped through all the init code and the > > > > > > > > > constructors > > > > > > > > > > on that second start-up, and whatever is going wrong is going > > > > > wrong > > > > > > > AFTER > > > > > > > > > > they have all run, and I don't know how to stop it at a point > > > > that > > > > > > > would > > > > > > > > > > give me any useful information about what is going wrong. > > > > > > > > > > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for > > > > PComm (I > > > > > > > shifted > > > > > > > > > > it from Var 100 to 80), the problem follows it to the new > > > > > location. So > > > > > > > > > it's > > > > > > > > > > not the specific location that's at issue, it has to be > > > > something > > > > > > > > > connected > > > > > > > > > > with that functionality. But we know the DSP side works fine, > > > > and > > > > > the > > > > > > > PC > > > > > > > > > > side isn't actually *doing* anything, other than writing that > > > > one > > > > > > > word. So > > > > > > > > > > what the heck is really happening? > > > > > > > > > > > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are > > > > > > > surrounded > > > > > > > > > > with locks, and I'm not doing anything that requires grabbing > > > > the > > > > > > > token > > > > > > > > > (the > > > > > > > > > > functions for doing Gather operations do use the token, but > > > > those > > > > > are > > > > > > > > > > commented out now). > > > > > > > > > > > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads > > > > > > > running: > > > > > > > > > > > > > 1) The main app thread > > > > > > > > > > > > > 2) A thread running the WCF server for the toolpath > > > > display > > > > > > > (which > > > > > > > > > is > > > > > > > > > > basically idle, since the toolpath window is not open) > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI > > > > updates > > > > > > > > > > > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec > > > > > rate, > > > > > > > mostly > > > > > > > > > > for periodically testing the connection, and updating the > > > > > "connected" > > > > > > > LED > > > > > > > > > in > > > > > > > > > > the GUI, and showing me the GUI state through a set of > > > > on-screen > > > > > > > > > checkboxes. > > > > > > > > > > This thread is the one that calls the PCComm handler. All Timer > > > > > > > methods > > > > > > > > > are > > > > > > > > > > very simple and lightweight. > > > > > > > > > > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if > > > > > that > > > > > > > would > > > > > > > > > > help. I'm truly stuck on this one. > > > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
|
|
Group: DynoMotion |
Message: 3650 |
From: himykabibble |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
Brad,
I'm not convinced the slowness I'm seeing is associated with any particular feature. It seems pretty random. I did find a bug in my StringGather that caused it to be transferring more data than it should have, but the overall update timing is slow, and quite variable, so I think it's either too much traffic, and/or a lot of blocking going on. I'm going to measure what the update loop time is. It's certainly not close to the 10/second it should be.
Is there any problem with asynchronous reads of GUI controls and other objects associated with the GUI thread?
I'd be curious what kind of update rate you see if you run the following on the DSP with a dotNet app. I see the messages coming about every 1/4 second or so, while under KMotion it looks like about 10/second, as it should be.
while(1)
{
int i;
printf )"1\n");
for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
printf )"2\n");
for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
printf )"3\n");
for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
}
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@...> wrote:
>
> ServiceConsole was not fully implemented, I wonder if that message pump is
> getting clogged.
>
>
>
> It is now implemented, as I saw it was being used in KMotionCNC.
>
>
>
> Not sure if that is a/the issue though.
>
>
>
> -Brad Murry
>
>
>
> From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> Behalf Of himykabibble
> Sent: Tuesday, January 31, 2012 10:00 PM
> To: DynoMotion@yahoogroups.com
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
>
>
>
> Tom/Brad,
>
> Earlier I was again seeing hangs associated with PCComm and/or Console
> messages. I added a message queue for the console messages, and it seems to
> be working solidly again, albeit slow. The GUI will sometimes become
> unresponsive for several seconds (up to 15 at times), then come back to
> life. Even when it's working, it seems sluggish to me. As I mentioned, the
> DROs seem to be updating only about 2-3 times per second. If I run a DSP
> program that does a printf every 2000 time slices, the messages come out at
> irregular intervals. If I send the messages through PCComm, both the average
> time, and the irregularity are much greater, with the bulk of time being
> spent doing the String gathers, which sometimes take as much as 2 or 3
> seconds to complete, for a message that is only about a dozen characters. I
> have to assume I still have some blocking problems. Any suggestions how to
> find them?
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> "himykabibble" <jagboy@> wrote:
> >
> > What I'm seeing right now is VERY long times to do the gather in PCComm to
> retrieve a short String - sometimes on the order of several seconds to
> retrieve a String that is perhaps a dozen characters. printfs are coming
> through reliably, and quickly. It seems to me like most operations that are
> talking to the board are taking an inordinately long time to complete,
> slowing everything down. I have no doubts this is a threading issue, but I
> don't know what, and VS2010 seems to provide no support for examining
> threads...
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> "himykabibble" <jagboy@> wrote:
> > >
> > > Unfortunately, my celebration turns out to be a bit premature. My
> deadlocks are back, after making a few minor changes.... I also noticed
> today while running on the machine that DRO updates are still very slow - on
> the order to 2-3 updates/seconds. I suspect there's a lot of waiting going
> on somewhere in there.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> , Andrew Ford <ahford@> wrote:
> > > >
> > > > I'm able to get the same hang in Kmotion with a printf every second or
> so.
> > > > I didn't take too close a look at it in the debugger but it looks like
> a
> > > > deadlock. I could take a closer look again tonight.
> > > >
> > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> > > >
> > > > > **
> > > > >
> > > > >
> > > > > Hi Ray,
> > > > >
> > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an
> App
> > > > > does a ReadLine from KFLOP the KMotionServer will do a read from
> KFLOP and
> > > > > may get back the unsolicited message instead of the expected
> response. In
> > > > > that case the unsolicited message received will be sent to the App
> via the
> > > > > ConsoleCallback and then another read will be performed to get the
> expected
> > > > > response.
> > > > >
> > > > > So from your description it seems like the crash is somehow being
> caused
> > > > > by the ConsoleCallback possibly due to a bug in the .Net interface
> or
> > > > > because the Console is doing something bad in your GUI. Maybe change
> the
> > > > > ConsoleCallback to just discard the message to help narrow things
> down.
> > > > >
> > > > > It isn't clear to me if the crash you report having in the
> MarshalPost is
> > > > > before the call or after.
> > > > >
> > > > > Regards
> > > > > TK
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > *From:* himykabibble <jagboy@>
> > > > > *To:* DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > *Sent:* Monday, January 30, 2012 4:14 PM
> > > > >
> > > > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > > Brad,
> > > > >
> > > > > As of last night, thanks to Toms suggestion to look at the DSP code,
> > > > > PCComm works, as does MDI from the DSP (and I assume most of the
> other
> > > > > functions, though I haven't tested them all yet). (Mind you, that
> same DSP
> > > > > code, printfs and all, works perfectly under KMotionCNC...) PCComm
> was
> > > > > "fixed" by getting rid of the printfs in the DSP code. Put the
> printfs
> > > > > back, and it starts locking up again (in CheckIsReady() before, but
> now in
> > > > > MarshalPost within WriteLineReadLine - At least it's a
> dead-consistent
> > > > > failure!). Console messages also work fine, as long as there are NO
> printfs
> > > > > in the DSP code.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote:
> > > > > >
> > > > > > Ray,
> > > > > >
> > > > > >
> > > > > >
> > > > > > I thought the main issue we were working on was the printf's/PComm
> > > > > issues in
> > > > > > your user programs, has that situation improved at all?
> > > > > >
> > > > > >
> > > > > >
> > > > > > Good that your MDI code works though.
> > > > > >
> > > > > >
> > > > > >
> > > > > > -Brad
> > > > > >
> > > > > >
> > > > > >
> > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > > Behalf Of himykabibble
> > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI
> problem,
> > > > > but I
> > > > > > still get the hangs in CheckIsRead() when I have the console
> callback
> > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > ,
> > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > >
> > > > > > >
> > > > > > > OK, now I can reliably run my InvokeAction() calls. I just
> needed to
> > > > > > invoke them. Kinda weird, you usually only need to invoke calls to
> your
> > > > > GUI
> > > > > > components, but in my case an HTML button is being clicked,
> handled by
> > > > > > jscript COM marshaling over to a method in my c# code. Maybe the
> printf
> > > > > is
> > > > > > using some [STAThread ] component..
> > > > > > >
> > > > > > >
> > > > > > > So Ray, surround your calls in an invoke clause as well and see
> if it
> > > > > > improves.
> > > > > > >
> > > > > > > Here is a nice tidy way to do it::
> > > > > > >
> > > > > > > public void UpdateDocument(Action action)
> > > > > > > {
> > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > {
> > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > }
> > > > > > > else
> > > > > > > {
> > > > > > > action();
> > > > > > > }
> > > > > > >
> > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > >
> > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > {
> > > > > > > //Your existing code inside here
> > > > > > > }
> > > > > > > ));
> > > > > > >
> > > > > > > Let me know if this helps.
> > > > > > >
> > > > > > > -Brad Murry
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > ,
> > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Hello Ray,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > You should invoke it to your textbox.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > In related news, I have no issues running any of my previously
> > > > > > problematic
> > > > > > > > procedures inside a console app.. Only crashes my winforms
> > > > > browserapp.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > ]
> > > > > > On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > >
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > I wired in the console message handler, and I now get frequent
> > > > > lock-ups.
> > > > > > My
> > > > > > > > handler does nothing more than one line of code that stuffs
> the
> > > > > String
> > > > > > > > argument into a TextBox. With that one line commented out, all
> is
> > > > > good.
> > > > > > But
> > > > > > > > if I uncomment that one line, then I get frequent hangs - the
> app
> > > > > just
> > > > > > locks
> > > > > > > > up. No errors, exceptions, or anything but the GUI stops
> responding
> > > > > > > > entirely. The callback does work as it should, until the app
> locks
> > > > > up.
> > > > > > Is
> > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > Well it makes me happy to see someone besides me having
> strange
> > > > > things
> > > > > > > > happening! :-) Hopefully when you get to the bottom of your
> problem
> > > > > it
> > > > > > will
> > > > > > > > fix mine as well.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > ,
> > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works
> just
> > > > > fine,
> > > > > > it
> > > > > > > > only
> > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user
> buttons. If
> > > > > you
> > > > > > look
> > > > > > > > at
> > > > > > > > > > the Ccode, it populates the MCodeActions as fires the
> button
> > > > > > commands as
> > > > > > > > if
> > > > > > > > > > they were any other MCode.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Still, it does not explain why it works for me and not you
> using
> > > > > the
> > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Then again, I am not using any PComm in my test
> prog(print.c).
> > > > > I'll
> > > > > > try
> > > > > > > > > > that and get back to you.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > No, I do not have the message event hooked up in my app.
> > > > > (Actually,
> > > > > > > > didn't
> > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > >
> > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > InvokeAction a
> > > > > > > > > > better way to do it?
> > > > > > > > > >
> > > > > > > > > > I've just run into a new problem as well. Two steps
> forward, one
> > > > > > > > > > backward.... MDI commands, which WERE working fine, now
> are not.
> > > > > > > > Non-motion
> > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> > > > > commands
> > > > > > never
> > > > > > > > > > issue a Completed callback. The move IS completed, I get
> the
> > > > > status
> > > > > > > > > > callback, then nothing. When I halt the interpreter, by
> hitting
> > > > > my
> > > > > > > > E-stop
> > > > > > > > > > button, or re-starting the App, THEN I get the completed
> > > > > callback.
> > > > > > So
> > > > > > > > > > something is blocking something there as well. This was
> working
> > > > > fine
> > > > > > > > until I
> > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hello Ray,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I am wondering if there are some .net memory sharing
> issues
> > > > > going
> > > > > > on
> > > > > > > > here.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I just set one of my user buttons to fire off the
> print.c
> > > > > program
> > > > > > and
> > > > > > > > I
> > > > > > > > > > get
> > > > > > > > > > > the same result.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I do, and I get the Hello, World message followed by an
> > > > > immediate
> > > > > > > > crash.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > It is interesting to note that we get the print messages
> just
> > > > > fine
> > > > > > > > from
> > > > > > > > > > the
> > > > > > > > > > > c# console application.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So I tried this code in my button event handler as a
> quick and
> > > > > > dirty
> > > > > > > > > > test::
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot +
> @"\C
> > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > >
> > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > TheCFile, false));
> > > > > > > > > > >
> > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > >
> > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > And I get my callbacks from the printf just fine!(no
> crashes).
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I looks like InvokeAction with printf's are doing
> something
> > > > > screwy
> > > > > > > > here.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Ray- Are you invoking your cprogram via
> > > > > Interpreter.InvokeAction
> > > > > > as
> > > > > > > > well?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Tom,
> > > > > > > > > > >
> > > > > > > > > > > I know this is a stupid question, but is there some
> > > > > interaction or
> > > > > > > > shared
> > > > > > > > > > > resources between the PCComm stuff/Gather buffer and
> printfs? I
> > > > > > had
> > > > > > > > some
> > > > > > > > > > > printfs in the Home code that I had put in while beating
> on
> > > > > this
> > > > > > > > thing. I
> > > > > > > > > > > just took them out, and it's now working. Nothing else
> has
> > > > > > changed.
> > > > > > > > > > printfs
> > > > > > > > > > > still do not come out in the KMotion console after I
> re-start
> > > > > my
> > > > > > app,
> > > > > > > > so
> > > > > > > > > > > there is something still not completely right, but
> PCComm is
> > > > > now
> > > > > > > > working,
> > > > > > > > > > so
> > > > > > > > > > > thanks for pointing me in the right direction. I just
> didn't
> > > > > even
> > > > > > > > really
> > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > KMotionCNC....
> > > > > > > > > > >
> > > > > > > > > > > What could cause KMotion to be able to talk to the board
> just
> > > > > > fine,
> > > > > > > > but
> > > > > > > > > > NOT
> > > > > > > > > > > see printfs? For that matter, when in that state, it
> does not
> > > > > see
> > > > > > DSP
> > > > > > > > > > tasks
> > > > > > > > > > > running either, as indficated as there are no green
> highlights
> > > > > on
> > > > > > the
> > > > > > > > task
> > > > > > > > > > > IDs next to the editor window. But after re-starting
> Kmotion,
> > > > > > without
> > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > The DSP code is my home function, which works
> perfectly under
> > > > > > > > > > KMotionCNC.
> > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > >
> > > > > > > > > > > > main()
> > > > > > > > > > > > {
> > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > This gives a different result. The first printf
> appears every
> > > > > > time.
> > > > > > > > The
> > > > > > > > > > > second one never appears. My app does not crash or
> behave
> > > > > > strangely in
> > > > > > > > any
> > > > > > > > > > > way that I can see, even if I open and close it several
> times.
> > > > > > But, if
> > > > > > > > I
> > > > > > > > > > > open KMotion, then open my app, then close it, then
> re-open it,
> > > > > > > > KMotion
> > > > > > > > > > will
> > > > > > > > > > > still be able to talk to the board, and execute commands
> from
> > > > > the
> > > > > > > > console,
> > > > > > > > > > > but printfs from the DSP no longer show up in the
> console
> > > > > window,
> > > > > > > > until I
> > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > >
> > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > influencing
> > > > > > > > the
> > > > > > > > > > > PCComm stuff. But what could that program be doing that
> it
> > > > > > wouldn't be
> > > > > > > > > > doing
> > > > > > > > > > > when run under KMotionCNC, where it's always works
> perfectly??
> > > > > > > > > > > >
> > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > >
> > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it
> sounds
> > > > > > more
> > > > > > > > like a
> > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC?
> What
> > > > > does
> > > > > > it
> > > > > > > > do
> > > > > > > > > > > after it sees the persist var cleared? What if you clear
> it
> > > > > from
> > > > > > the
> > > > > > > > > > KMotion
> > > > > > > > > > > Console instead? Otherwise I can look at if you post all
> the
> > > > > code.
> > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > TK
> > > > > > > > > > > > >
> > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble"
> <jagboy@>
> > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> > > > > suggestions
> > > > > > on
> > > > > > > > how
> > > > > > > > > > to
> > > > > > > > > > > proceed. As long as I don't touch Persist[100],
> everything
> > > > > works
> > > > > > just
> > > > > > > > > > fine.
> > > > > > > > > > > I can start my app, run programs, exit, connect,
> disconnect,
> > > > > and
> > > > > > it
> > > > > > > > seems
> > > > > > > > > > to
> > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side,
> my
> > > > > PCComm
> > > > > > code
> > > > > > > > > > > correctly processes it, and clears Persist[100], and
> shortly
> > > > > after
> > > > > > > > that,
> > > > > > > > > > the
> > > > > > > > > > > board "goes missing", and I get the dialog asking me if
> I want
> > > > > to
> > > > > > run
> > > > > > > > the
> > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> > > > > VS2008,
> > > > > > even
> > > > > > > > > > though
> > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug"
> prompt,
> > > > > it
> > > > > > opens
> > > > > > > > > > > VS2008, loads the current source file, and that's it. No
> > > > > debugger,
> > > > > > no
> > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing,
> due to
> > > > > > having
> > > > > > > > both
> > > > > > > > > > > versions installed, but I not only don't know how to fix
> it, I
> > > > > am
> > > > > > > > > > reluctant
> > > > > > > > > > > to try to get 2008 working in that context, for fear it
> will
> > > > > screw
> > > > > > up
> > > > > > > > > > 2010,
> > > > > > > > > > > which is what I generally use. I only installed 2008 to
> be
> > > > > able to
> > > > > > > > build
> > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Anyway, I am convinced it is clearing
> Persist[100], while
> > > > > > not
> > > > > > > > the
> > > > > > > > > > > actual cause of the problem, is somehow triggering
> whatever it
> > > > > is
> > > > > > that
> > > > > > > > is
> > > > > > > > > > > going wrong, but I'm totally at a loss to understand
> what is
> > > > > going
> > > > > > > > wrong,
> > > > > > > > > > or
> > > > > > > > > > > how, and have had no success in trying to narrow it
> down. If I
> > > > > > comment
> > > > > > > > out
> > > > > > > > > > > the one line that clears Persist[100] after a PCComm
> command,
> > > > > the
> > > > > > > > problem
> > > > > > > > > > > goes away entirely, and everything works perfectly. If I
> change
> > > > > > that
> > > > > > > > one
> > > > > > > > > > > line to write *any* other location, like 99, or 101, the
> > > > > failure
> > > > > > > > > > "signature"
> > > > > > > > > > > changes - rather than crashing almost immediately after
> the
> > > > > > Persist
> > > > > > > > > > location
> > > > > > > > > > > is written, the app continues to run normally until I
> close
> > > > > it.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > But, if I then re-start the app without first
> > > > > disconnecting
> > > > > > and
> > > > > > > > > > > reconnecting the board, I get the debug dialog again as
> soon as
> > > > > > the
> > > > > > > > new
> > > > > > > > > > app
> > > > > > > > > > > instance recognizes the connection is available, and
> does its
> > > > > > > > > > KM_Controller
> > > > > > > > > > > initialization. I've stepped through all the init code
> and the
> > > > > > > > > > constructors
> > > > > > > > > > > on that second start-up, and whatever is going wrong is
> going
> > > > > > wrong
> > > > > > > > AFTER
> > > > > > > > > > > they have all run, and I don't know how to stop it at a
> point
> > > > > that
> > > > > > > > would
> > > > > > > > > > > give me any useful information about what is going
> wrong.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Not surprisingly, if I change the location used
> for
> > > > > PComm (I
> > > > > > > > shifted
> > > > > > > > > > > it from Var 100 to 80), the problem follows it to the
> new
> > > > > > location. So
> > > > > > > > > > it's
> > > > > > > > > > > not the specific location that's at issue, it has to be
> > > > > something
> > > > > > > > > > connected
> > > > > > > > > > > with that functionality. But we know the DSP side works
> fine,
> > > > > and
> > > > > > the
> > > > > > > > PC
> > > > > > > > > > > side isn't actually *doing* anything, other than writing
> that
> > > > > one
> > > > > > > > word. So
> > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've double-checked and all my KM_Controller
> accesses are
> > > > > > > > surrounded
> > > > > > > > > > > with locks, and I'm not doing anything that requires
> grabbing
> > > > > the
> > > > > > > > token
> > > > > > > > > > (the
> > > > > > > > > > > functions for doing Gather operations do use the token,
> but
> > > > > those
> > > > > > are
> > > > > > > > > > > commented out now).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > At the point where it's crashing, there are three
> threads
> > > > > > > > running:
> > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > 2) A thread running the WCF server for the
> toolpath
> > > > > display
> > > > > > > > (which
> > > > > > > > > > is
> > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> > > > > updates
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > The app thread also has one Timer running, at a
> 100mSec
> > > > > > rate,
> > > > > > > > mostly
> > > > > > > > > > > for periodically testing the connection, and updating
> the
> > > > > > "connected"
> > > > > > > > LED
> > > > > > > > > > in
> > > > > > > > > > > the GUI, and showing me the GUI state through a set of
> > > > > on-screen
> > > > > > > > > > checkboxes.
> > > > > > > > > > > This thread is the one that calls the PCComm handler.
> All Timer
> > > > > > > > methods
> > > > > > > > > > are
> > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my
> code if
> > > > > > that
> > > > > > > > would
> > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3651 |
From: himykabibble |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
OK, I just did a little testing, and got a very surprising and confusing result. I put a Stopwatch in my update Do_Work method, and count how many updates are done every 5 seconds. With everything running, my update rate is only about 15-20 updates every 5 seconds, which is far less than it should be. So I started eliminating things to see what was dragging it down. If I comment out all the calls to dotNet in the update loop, leaving all of my code still running, the update rate jumps up to 80-100 updates every 5 seconds. If I put back a SINGLE call into dotNet (getting axis position), this drops to a HIGHLY variable 25-60 updates every 5 seconds. The really interesting thing is putting ALL of the dotNet accesses back in does not seem to slow it down any further than just the one. I believe this is conclusive proof that the performance of my code is not the gating issue (I didn't think it was, but it's nice to know for sure). But how can a single dotNet call slow things down so much?
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Brad,
>
> I'm not convinced the slowness I'm seeing is associated with any particular feature. It seems pretty random. I did find a bug in my StringGather that caused it to be transferring more data than it should have, but the overall update timing is slow, and quite variable, so I think it's either too much traffic, and/or a lot of blocking going on. I'm going to measure what the update loop time is. It's certainly not close to the 10/second it should be.
>
> Is there any problem with asynchronous reads of GUI controls and other objects associated with the GUI thread?
>
> I'd be curious what kind of update rate you see if you run the following on the DSP with a dotNet app. I see the messages coming about every 1/4 second or so, while under KMotion it looks like about 10/second, as it should be.
>
> while(1)
> {
> int i;
> printf )"1\n");
> for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> printf )"2\n");
> for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> printf )"3\n");
> for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> }
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> >
> > ServiceConsole was not fully implemented, I wonder if that message pump is
> > getting clogged.
> >
> >
> >
> > It is now implemented, as I saw it was being used in KMotionCNC.
> >
> >
> >
> > Not sure if that is a/the issue though.
> >
> >
> >
> > -Brad Murry
> >
> >
> >
> > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > Behalf Of himykabibble
> > Sent: Tuesday, January 31, 2012 10:00 PM
> > To: DynoMotion@yahoogroups.com
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> >
> >
> >
> > Tom/Brad,
> >
> > Earlier I was again seeing hangs associated with PCComm and/or Console
> > messages. I added a message queue for the console messages, and it seems to
> > be working solidly again, albeit slow. The GUI will sometimes become
> > unresponsive for several seconds (up to 15 at times), then come back to
> > life. Even when it's working, it seems sluggish to me. As I mentioned, the
> > DROs seem to be updating only about 2-3 times per second. If I run a DSP
> > program that does a printf every 2000 time slices, the messages come out at
> > irregular intervals. If I send the messages through PCComm, both the average
> > time, and the irregularity are much greater, with the bulk of time being
> > spent doing the String gathers, which sometimes take as much as 2 or 3
> > seconds to complete, for a message that is only about a dozen characters. I
> > have to assume I still have some blocking problems. Any suggestions how to
> > find them?
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > "himykabibble" <jagboy@> wrote:
> > >
> > > What I'm seeing right now is VERY long times to do the gather in PCComm to
> > retrieve a short String - sometimes on the order of several seconds to
> > retrieve a String that is perhaps a dozen characters. printfs are coming
> > through reliably, and quickly. It seems to me like most operations that are
> > talking to the board are taking an inordinately long time to complete,
> > slowing everything down. I have no doubts this is a threading issue, but I
> > don't know what, and VS2010 seems to provide no support for examining
> > threads...
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > "himykabibble" <jagboy@> wrote:
> > > >
> > > > Unfortunately, my celebration turns out to be a bit premature. My
> > deadlocks are back, after making a few minor changes.... I also noticed
> > today while running on the machine that DRO updates are still very slow - on
> > the order to 2-3 updates/seconds. I suspect there's a lot of waiting going
> > on somewhere in there.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > , Andrew Ford <ahford@> wrote:
> > > > >
> > > > > I'm able to get the same hang in Kmotion with a printf every second or
> > so.
> > > > > I didn't take too close a look at it in the debugger but it looks like
> > a
> > > > > deadlock. I could take a closer look again tonight.
> > > > >
> > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > > **
> > > > > >
> > > > > >
> > > > > > Hi Ray,
> > > > > >
> > > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an
> > App
> > > > > > does a ReadLine from KFLOP the KMotionServer will do a read from
> > KFLOP and
> > > > > > may get back the unsolicited message instead of the expected
> > response. In
> > > > > > that case the unsolicited message received will be sent to the App
> > via the
> > > > > > ConsoleCallback and then another read will be performed to get the
> > expected
> > > > > > response.
> > > > > >
> > > > > > So from your description it seems like the crash is somehow being
> > caused
> > > > > > by the ConsoleCallback possibly due to a bug in the .Net interface
> > or
> > > > > > because the Console is doing something bad in your GUI. Maybe change
> > the
> > > > > > ConsoleCallback to just discard the message to help narrow things
> > down.
> > > > > >
> > > > > > It isn't clear to me if the crash you report having in the
> > MarshalPost is
> > > > > > before the call or after.
> > > > > >
> > > > > > Regards
> > > > > > TK
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > *From:* himykabibble <jagboy@>
> > > > > > *To:* DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > *Sent:* Monday, January 30, 2012 4:14 PM
> > > > > >
> > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > As of last night, thanks to Toms suggestion to look at the DSP code,
> > > > > > PCComm works, as does MDI from the DSP (and I assume most of the
> > other
> > > > > > functions, though I haven't tested them all yet). (Mind you, that
> > same DSP
> > > > > > code, printfs and all, works perfectly under KMotionCNC...) PCComm
> > was
> > > > > > "fixed" by getting rid of the printfs in the DSP code. Put the
> > printfs
> > > > > > back, and it starts locking up again (in CheckIsReady() before, but
> > now in
> > > > > > MarshalPost within WriteLineReadLine - At least it's a
> > dead-consistent
> > > > > > failure!). Console messages also work fine, as long as there are NO
> > printfs
> > > > > > in the DSP code.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I thought the main issue we were working on was the printf's/PComm
> > > > > > issues in
> > > > > > > your user programs, has that situation improved at all?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Good that your MDI code works though.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI
> > problem,
> > > > > > but I
> > > > > > > still get the hangs in CheckIsRead() when I have the console
> > callback
> > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ,
> > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just
> > needed to
> > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to
> > your
> > > > > > GUI
> > > > > > > components, but in my case an HTML button is being clicked,
> > handled by
> > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the
> > printf
> > > > > > is
> > > > > > > using some [STAThread ] component..
> > > > > > > >
> > > > > > > >
> > > > > > > > So Ray, surround your calls in an invoke clause as well and see
> > if it
> > > > > > > improves.
> > > > > > > >
> > > > > > > > Here is a nice tidy way to do it::
> > > > > > > >
> > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > {
> > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > {
> > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > }
> > > > > > > > else
> > > > > > > > {
> > > > > > > > action();
> > > > > > > > }
> > > > > > > >
> > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > >
> > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > {
> > > > > > > > //Your existing code inside here
> > > > > > > > }
> > > > > > > > ));
> > > > > > > >
> > > > > > > > Let me know if this helps.
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Hello Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > You should invoke it to your textbox.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > problematic
> > > > > > > > > procedures inside a console app.. Only crashes my winforms
> > > > > > browserapp.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > >
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > I wired in the console message handler, and I now get frequent
> > > > > > lock-ups.
> > > > > > > My
> > > > > > > > > handler does nothing more than one line of code that stuffs
> > the
> > > > > > String
> > > > > > > > > argument into a TextBox. With that one line commented out, all
> > is
> > > > > > good.
> > > > > > > But
> > > > > > > > > if I uncomment that one line, then I get frequent hangs - the
> > app
> > > > > > just
> > > > > > > locks
> > > > > > > > > up. No errors, exceptions, or anything but the GUI stops
> > responding
> > > > > > > > > entirely. The callback does work as it should, until the app
> > locks
> > > > > > up.
> > > > > > > Is
> > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Well it makes me happy to see someone besides me having
> > strange
> > > > > > things
> > > > > > > > > happening! :-) Hopefully when you get to the bottom of your
> > problem
> > > > > > it
> > > > > > > will
> > > > > > > > > fix mine as well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works
> > just
> > > > > > fine,
> > > > > > > it
> > > > > > > > > only
> > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user
> > buttons. If
> > > > > > you
> > > > > > > look
> > > > > > > > > at
> > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the
> > button
> > > > > > > commands as
> > > > > > > > > if
> > > > > > > > > > > they were any other MCode.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Still, it does not explain why it works for me and not you
> > using
> > > > > > the
> > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Then again, I am not using any PComm in my test
> > prog(print.c).
> > > > > > I'll
> > > > > > > try
> > > > > > > > > > > that and get back to you.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > No, I do not have the message event hooked up in my app.
> > > > > > (Actually,
> > > > > > > > > didn't
> > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > >
> > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > InvokeAction a
> > > > > > > > > > > better way to do it?
> > > > > > > > > > >
> > > > > > > > > > > I've just run into a new problem as well. Two steps
> > forward, one
> > > > > > > > > > > backward.... MDI commands, which WERE working fine, now
> > are not.
> > > > > > > > > Non-motion
> > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> > > > > > commands
> > > > > > > never
> > > > > > > > > > > issue a Completed callback. The move IS completed, I get
> > the
> > > > > > status
> > > > > > > > > > > callback, then nothing. When I halt the interpreter, by
> > hitting
> > > > > > my
> > > > > > > > > E-stop
> > > > > > > > > > > button, or re-starting the App, THEN I get the completed
> > > > > > callback.
> > > > > > > So
> > > > > > > > > > > something is blocking something there as well. This was
> > working
> > > > > > fine
> > > > > > > > > until I
> > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I am wondering if there are some .net memory sharing
> > issues
> > > > > > going
> > > > > > > on
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I just set one of my user buttons to fire off the
> > print.c
> > > > > > program
> > > > > > > and
> > > > > > > > > I
> > > > > > > > > > > get
> > > > > > > > > > > > the same result.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I do, and I get the Hello, World message followed by an
> > > > > > immediate
> > > > > > > > > crash.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > It is interesting to note that we get the print messages
> > just
> > > > > > fine
> > > > > > > > > from
> > > > > > > > > > > the
> > > > > > > > > > > > c# console application.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > So I tried this code in my button event handler as a
> > quick and
> > > > > > > dirty
> > > > > > > > > > > test::
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot +
> > @"\C
> > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > >
> > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > >
> > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > And I get my callbacks from the printf just fine!(no
> > crashes).
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I looks like InvokeAction with printf's are doing
> > something
> > > > > > screwy
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Ray- Are you invoking your cprogram via
> > > > > > Interpreter.InvokeAction
> > > > > > > as
> > > > > > > > > well?
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > I know this is a stupid question, but is there some
> > > > > > interaction or
> > > > > > > > > shared
> > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and
> > printfs? I
> > > > > > > had
> > > > > > > > > some
> > > > > > > > > > > > printfs in the Home code that I had put in while beating
> > on
> > > > > > this
> > > > > > > > > thing. I
> > > > > > > > > > > > just took them out, and it's now working. Nothing else
> > has
> > > > > > > changed.
> > > > > > > > > > > printfs
> > > > > > > > > > > > still do not come out in the KMotion console after I
> > re-start
> > > > > > my
> > > > > > > app,
> > > > > > > > > so
> > > > > > > > > > > > there is something still not completely right, but
> > PCComm is
> > > > > > now
> > > > > > > > > working,
> > > > > > > > > > > so
> > > > > > > > > > > > thanks for pointing me in the right direction. I just
> > didn't
> > > > > > even
> > > > > > > > > really
> > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > KMotionCNC....
> > > > > > > > > > > >
> > > > > > > > > > > > What could cause KMotion to be able to talk to the board
> > just
> > > > > > > fine,
> > > > > > > > > but
> > > > > > > > > > > NOT
> > > > > > > > > > > > see printfs? For that matter, when in that state, it
> > does not
> > > > > > see
> > > > > > > DSP
> > > > > > > > > > > tasks
> > > > > > > > > > > > running either, as indficated as there are no green
> > highlights
> > > > > > on
> > > > > > > the
> > > > > > > > > task
> > > > > > > > > > > > IDs next to the editor window. But after re-starting
> > Kmotion,
> > > > > > > without
> > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Tom,
> > > > > > > > > > > > >
> > > > > > > > > > > > > The DSP code is my home function, which works
> > perfectly under
> > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > >
> > > > > > > > > > > > > main()
> > > > > > > > > > > > > {
> > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > This gives a different result. The first printf
> > appears every
> > > > > > > time.
> > > > > > > > > The
> > > > > > > > > > > > second one never appears. My app does not crash or
> > behave
> > > > > > > strangely in
> > > > > > > > > any
> > > > > > > > > > > > way that I can see, even if I open and close it several
> > times.
> > > > > > > But, if
> > > > > > > > > I
> > > > > > > > > > > > open KMotion, then open my app, then close it, then
> > re-open it,
> > > > > > > > > KMotion
> > > > > > > > > > > will
> > > > > > > > > > > > still be able to talk to the board, and execute commands
> > from
> > > > > > the
> > > > > > > > > console,
> > > > > > > > > > > > but printfs from the DSP no longer show up in the
> > console
> > > > > > window,
> > > > > > > > > until I
> > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > influencing
> > > > > > > > > the
> > > > > > > > > > > > PCComm stuff. But what could that program be doing that
> > it
> > > > > > > wouldn't be
> > > > > > > > > > > doing
> > > > > > > > > > > > when run under KMotionCNC, where it's always works
> > perfectly??
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it
> > sounds
> > > > > > > more
> > > > > > > > > like a
> > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC?
> > What
> > > > > > does
> > > > > > > it
> > > > > > > > > do
> > > > > > > > > > > > after it sees the persist var cleared? What if you clear
> > it
> > > > > > from
> > > > > > > the
> > > > > > > > > > > KMotion
> > > > > > > > > > > > Console instead? Otherwise I can look at if you post all
> > the
> > > > > > code.
> > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > TK
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble"
> > <jagboy@>
> > > > > > wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> > > > > > suggestions
> > > > > > > on
> > > > > > > > > how
> > > > > > > > > > > to
> > > > > > > > > > > > proceed. As long as I don't touch Persist[100],
> > everything
> > > > > > works
> > > > > > > just
> > > > > > > > > > > fine.
> > > > > > > > > > > > I can start my app, run programs, exit, connect,
> > disconnect,
> > > > > > and
> > > > > > > it
> > > > > > > > > seems
> > > > > > > > > > > to
> > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side,
> > my
> > > > > > PCComm
> > > > > > > code
> > > > > > > > > > > > correctly processes it, and clears Persist[100], and
> > shortly
> > > > > > after
> > > > > > > > > that,
> > > > > > > > > > > the
> > > > > > > > > > > > board "goes missing", and I get the dialog asking me if
> > I want
> > > > > > to
> > > > > > > run
> > > > > > > > > the
> > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> > > > > > VS2008,
> > > > > > > even
> > > > > > > > > > > though
> > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug"
> > prompt,
> > > > > > it
> > > > > > > opens
> > > > > > > > > > > > VS2008, loads the current source file, and that's it. No
> > > > > > debugger,
> > > > > > > no
> > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing,
> > due to
> > > > > > > having
> > > > > > > > > both
> > > > > > > > > > > > versions installed, but I not only don't know how to fix
> > it, I
> > > > > > am
> > > > > > > > > > > reluctant
> > > > > > > > > > > > to try to get 2008 working in that context, for fear it
> > will
> > > > > > screw
> > > > > > > up
> > > > > > > > > > > 2010,
> > > > > > > > > > > > which is what I generally use. I only installed 2008 to
> > be
> > > > > > able to
> > > > > > > > > build
> > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Anyway, I am convinced it is clearing
> > Persist[100], while
> > > > > > > not
> > > > > > > > > the
> > > > > > > > > > > > actual cause of the problem, is somehow triggering
> > whatever it
> > > > > > is
> > > > > > > that
> > > > > > > > > is
> > > > > > > > > > > > going wrong, but I'm totally at a loss to understand
> > what is
> > > > > > going
> > > > > > > > > wrong,
> > > > > > > > > > > or
> > > > > > > > > > > > how, and have had no success in trying to narrow it
> > down. If I
> > > > > > > comment
> > > > > > > > > out
> > > > > > > > > > > > the one line that clears Persist[100] after a PCComm
> > command,
> > > > > > the
> > > > > > > > > problem
> > > > > > > > > > > > goes away entirely, and everything works perfectly. If I
> > change
> > > > > > > that
> > > > > > > > > one
> > > > > > > > > > > > line to write *any* other location, like 99, or 101, the
> > > > > > failure
> > > > > > > > > > > "signature"
> > > > > > > > > > > > changes - rather than crashing almost immediately after
> > the
> > > > > > > Persist
> > > > > > > > > > > location
> > > > > > > > > > > > is written, the app continues to run normally until I
> > close
> > > > > > it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > But, if I then re-start the app without first
> > > > > > disconnecting
> > > > > > > and
> > > > > > > > > > > > reconnecting the board, I get the debug dialog again as
> > soon as
> > > > > > > the
> > > > > > > > > new
> > > > > > > > > > > app
> > > > > > > > > > > > instance recognizes the connection is available, and
> > does its
> > > > > > > > > > > KM_Controller
> > > > > > > > > > > > initialization. I've stepped through all the init code
> > and the
> > > > > > > > > > > constructors
> > > > > > > > > > > > on that second start-up, and whatever is going wrong is
> > going
> > > > > > > wrong
> > > > > > > > > AFTER
> > > > > > > > > > > > they have all run, and I don't know how to stop it at a
> > point
> > > > > > that
> > > > > > > > > would
> > > > > > > > > > > > give me any useful information about what is going
> > wrong.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Not surprisingly, if I change the location used
> > for
> > > > > > PComm (I
> > > > > > > > > shifted
> > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the
> > new
> > > > > > > location. So
> > > > > > > > > > > it's
> > > > > > > > > > > > not the specific location that's at issue, it has to be
> > > > > > something
> > > > > > > > > > > connected
> > > > > > > > > > > > with that functionality. But we know the DSP side works
> > fine,
> > > > > > and
> > > > > > > the
> > > > > > > > > PC
> > > > > > > > > > > > side isn't actually *doing* anything, other than writing
> > that
> > > > > > one
> > > > > > > > > word. So
> > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've double-checked and all my KM_Controller
> > accesses are
> > > > > > > > > surrounded
> > > > > > > > > > > > with locks, and I'm not doing anything that requires
> > grabbing
> > > > > > the
> > > > > > > > > token
> > > > > > > > > > > (the
> > > > > > > > > > > > functions for doing Gather operations do use the token,
> > but
> > > > > > those
> > > > > > > are
> > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > At the point where it's crashing, there are three
> > threads
> > > > > > > > > running:
> > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > 2) A thread running the WCF server for the
> > toolpath
> > > > > > display
> > > > > > > > > (which
> > > > > > > > > > > is
> > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> > > > > > updates
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The app thread also has one Timer running, at a
> > 100mSec
> > > > > > > rate,
> > > > > > > > > mostly
> > > > > > > > > > > > for periodically testing the connection, and updating
> > the
> > > > > > > "connected"
> > > > > > > > > LED
> > > > > > > > > > > in
> > > > > > > > > > > > the GUI, and showing me the GUI state through a set of
> > > > > > on-screen
> > > > > > > > > > > checkboxes.
> > > > > > > > > > > > This thread is the one that calls the PCComm handler.
> > All Timer
> > > > > > > > > methods
> > > > > > > > > > > are
> > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my
> > code if
> > > > > > > that
> > > > > > > > > would
> > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3652 |
From: himykabibble |
Date: 1/31/2012 |
Subject: Re: Need Some Ideas.... |
BTW - I am no longer seeing ANY hangs, even when I hammer it with printfs and PCComms.
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Brad,
>
> I'm not convinced the slowness I'm seeing is associated with any particular feature. It seems pretty random. I did find a bug in my StringGather that caused it to be transferring more data than it should have, but the overall update timing is slow, and quite variable, so I think it's either too much traffic, and/or a lot of blocking going on. I'm going to measure what the update loop time is. It's certainly not close to the 10/second it should be.
>
> Is there any problem with asynchronous reads of GUI controls and other objects associated with the GUI thread?
>
> I'd be curious what kind of update rate you see if you run the following on the DSP with a dotNet app. I see the messages coming about every 1/4 second or so, while under KMotion it looks like about 10/second, as it should be.
>
> while(1)
> {
> int i;
> printf )"1\n");
> for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> printf )"2\n");
> for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> printf )"3\n");
> for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> }
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> >
> > ServiceConsole was not fully implemented, I wonder if that message pump is
> > getting clogged.
> >
> >
> >
> > It is now implemented, as I saw it was being used in KMotionCNC.
> >
> >
> >
> > Not sure if that is a/the issue though.
> >
> >
> >
> > -Brad Murry
> >
> >
> >
> > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > Behalf Of himykabibble
> > Sent: Tuesday, January 31, 2012 10:00 PM
> > To: DynoMotion@yahoogroups.com
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> >
> >
> >
> > Tom/Brad,
> >
> > Earlier I was again seeing hangs associated with PCComm and/or Console
> > messages. I added a message queue for the console messages, and it seems to
> > be working solidly again, albeit slow. The GUI will sometimes become
> > unresponsive for several seconds (up to 15 at times), then come back to
> > life. Even when it's working, it seems sluggish to me. As I mentioned, the
> > DROs seem to be updating only about 2-3 times per second. If I run a DSP
> > program that does a printf every 2000 time slices, the messages come out at
> > irregular intervals. If I send the messages through PCComm, both the average
> > time, and the irregularity are much greater, with the bulk of time being
> > spent doing the String gathers, which sometimes take as much as 2 or 3
> > seconds to complete, for a message that is only about a dozen characters. I
> > have to assume I still have some blocking problems. Any suggestions how to
> > find them?
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > "himykabibble" <jagboy@> wrote:
> > >
> > > What I'm seeing right now is VERY long times to do the gather in PCComm to
> > retrieve a short String - sometimes on the order of several seconds to
> > retrieve a String that is perhaps a dozen characters. printfs are coming
> > through reliably, and quickly. It seems to me like most operations that are
> > talking to the board are taking an inordinately long time to complete,
> > slowing everything down. I have no doubts this is a threading issue, but I
> > don't know what, and VS2010 seems to provide no support for examining
> > threads...
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > "himykabibble" <jagboy@> wrote:
> > > >
> > > > Unfortunately, my celebration turns out to be a bit premature. My
> > deadlocks are back, after making a few minor changes.... I also noticed
> > today while running on the machine that DRO updates are still very slow - on
> > the order to 2-3 updates/seconds. I suspect there's a lot of waiting going
> > on somewhere in there.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > , Andrew Ford <ahford@> wrote:
> > > > >
> > > > > I'm able to get the same hang in Kmotion with a printf every second or
> > so.
> > > > > I didn't take too close a look at it in the debugger but it looks like
> > a
> > > > > deadlock. I could take a closer look again tonight.
> > > > >
> > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> > > > >
> > > > > > **
> > > > > >
> > > > > >
> > > > > > Hi Ray,
> > > > > >
> > > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an
> > App
> > > > > > does a ReadLine from KFLOP the KMotionServer will do a read from
> > KFLOP and
> > > > > > may get back the unsolicited message instead of the expected
> > response. In
> > > > > > that case the unsolicited message received will be sent to the App
> > via the
> > > > > > ConsoleCallback and then another read will be performed to get the
> > expected
> > > > > > response.
> > > > > >
> > > > > > So from your description it seems like the crash is somehow being
> > caused
> > > > > > by the ConsoleCallback possibly due to a bug in the .Net interface
> > or
> > > > > > because the Console is doing something bad in your GUI. Maybe change
> > the
> > > > > > ConsoleCallback to just discard the message to help narrow things
> > down.
> > > > > >
> > > > > > It isn't clear to me if the crash you report having in the
> > MarshalPost is
> > > > > > before the call or after.
> > > > > >
> > > > > > Regards
> > > > > > TK
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > *From:* himykabibble <jagboy@>
> > > > > > *To:* DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > *Sent:* Monday, January 30, 2012 4:14 PM
> > > > > >
> > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > > Brad,
> > > > > >
> > > > > > As of last night, thanks to Toms suggestion to look at the DSP code,
> > > > > > PCComm works, as does MDI from the DSP (and I assume most of the
> > other
> > > > > > functions, though I haven't tested them all yet). (Mind you, that
> > same DSP
> > > > > > code, printfs and all, works perfectly under KMotionCNC...) PCComm
> > was
> > > > > > "fixed" by getting rid of the printfs in the DSP code. Put the
> > printfs
> > > > > > back, and it starts locking up again (in CheckIsReady() before, but
> > now in
> > > > > > MarshalPost within WriteLineReadLine - At least it's a
> > dead-consistent
> > > > > > failure!). Console messages also work fine, as long as there are NO
> > printfs
> > > > > > in the DSP code.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote:
> > > > > > >
> > > > > > > Ray,
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > I thought the main issue we were working on was the printf's/PComm
> > > > > > issues in
> > > > > > > your user programs, has that situation improved at all?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Good that your MDI code works though.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > -Brad
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > > > Behalf Of himykabibble
> > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI
> > problem,
> > > > > > but I
> > > > > > > still get the hangs in CheckIsRead() when I have the console
> > callback
> > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ,
> > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just
> > needed to
> > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to
> > your
> > > > > > GUI
> > > > > > > components, but in my case an HTML button is being clicked,
> > handled by
> > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the
> > printf
> > > > > > is
> > > > > > > using some [STAThread ] component..
> > > > > > > >
> > > > > > > >
> > > > > > > > So Ray, surround your calls in an invoke clause as well and see
> > if it
> > > > > > > improves.
> > > > > > > >
> > > > > > > > Here is a nice tidy way to do it::
> > > > > > > >
> > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > {
> > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > {
> > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > }
> > > > > > > > else
> > > > > > > > {
> > > > > > > > action();
> > > > > > > > }
> > > > > > > >
> > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > >
> > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > {
> > > > > > > > //Your existing code inside here
> > > > > > > > }
> > > > > > > > ));
> > > > > > > >
> > > > > > > > Let me know if this helps.
> > > > > > > >
> > > > > > > > -Brad Murry
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ,
> > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Hello Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > You should invoke it to your textbox.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > problematic
> > > > > > > > > procedures inside a console app.. Only crashes my winforms
> > > > > > browserapp.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > ]
> > > > > > > On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > >
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > I wired in the console message handler, and I now get frequent
> > > > > > lock-ups.
> > > > > > > My
> > > > > > > > > handler does nothing more than one line of code that stuffs
> > the
> > > > > > String
> > > > > > > > > argument into a TextBox. With that one line commented out, all
> > is
> > > > > > good.
> > > > > > > But
> > > > > > > > > if I uncomment that one line, then I get frequent hangs - the
> > app
> > > > > > just
> > > > > > > locks
> > > > > > > > > up. No errors, exceptions, or anything but the GUI stops
> > responding
> > > > > > > > > entirely. The callback does work as it should, until the app
> > locks
> > > > > > up.
> > > > > > > Is
> > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Well it makes me happy to see someone besides me having
> > strange
> > > > > > things
> > > > > > > > > happening! :-) Hopefully when you get to the bottom of your
> > problem
> > > > > > it
> > > > > > > will
> > > > > > > > > fix mine as well.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works
> > just
> > > > > > fine,
> > > > > > > it
> > > > > > > > > only
> > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user
> > buttons. If
> > > > > > you
> > > > > > > look
> > > > > > > > > at
> > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the
> > button
> > > > > > > commands as
> > > > > > > > > if
> > > > > > > > > > > they were any other MCode.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Still, it does not explain why it works for me and not you
> > using
> > > > > > the
> > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Then again, I am not using any PComm in my test
> > prog(print.c).
> > > > > > I'll
> > > > > > > try
> > > > > > > > > > > that and get back to you.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > No, I do not have the message event hooked up in my app.
> > > > > > (Actually,
> > > > > > > > > didn't
> > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > >
> > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > InvokeAction a
> > > > > > > > > > > better way to do it?
> > > > > > > > > > >
> > > > > > > > > > > I've just run into a new problem as well. Two steps
> > forward, one
> > > > > > > > > > > backward.... MDI commands, which WERE working fine, now
> > are not.
> > > > > > > > > Non-motion
> > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> > > > > > commands
> > > > > > > never
> > > > > > > > > > > issue a Completed callback. The move IS completed, I get
> > the
> > > > > > status
> > > > > > > > > > > callback, then nothing. When I halt the interpreter, by
> > hitting
> > > > > > my
> > > > > > > > > E-stop
> > > > > > > > > > > button, or re-starting the App, THEN I get the completed
> > > > > > callback.
> > > > > > > So
> > > > > > > > > > > something is blocking something there as well. This was
> > working
> > > > > > fine
> > > > > > > > > until I
> > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I am wondering if there are some .net memory sharing
> > issues
> > > > > > going
> > > > > > > on
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I just set one of my user buttons to fire off the
> > print.c
> > > > > > program
> > > > > > > and
> > > > > > > > > I
> > > > > > > > > > > get
> > > > > > > > > > > > the same result.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I do, and I get the Hello, World message followed by an
> > > > > > immediate
> > > > > > > > > crash.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > It is interesting to note that we get the print messages
> > just
> > > > > > fine
> > > > > > > > > from
> > > > > > > > > > > the
> > > > > > > > > > > > c# console application.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > So I tried this code in my button event handler as a
> > quick and
> > > > > > > dirty
> > > > > > > > > > > test::
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot +
> > @"\C
> > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > >
> > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > >
> > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > >
> > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > And I get my callbacks from the printf just fine!(no
> > crashes).
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I looks like InvokeAction with printf's are doing
> > something
> > > > > > screwy
> > > > > > > > > here.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Ray- Are you invoking your cprogram via
> > > > > > Interpreter.InvokeAction
> > > > > > > as
> > > > > > > > > well?
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Tom,
> > > > > > > > > > > >
> > > > > > > > > > > > I know this is a stupid question, but is there some
> > > > > > interaction or
> > > > > > > > > shared
> > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and
> > printfs? I
> > > > > > > had
> > > > > > > > > some
> > > > > > > > > > > > printfs in the Home code that I had put in while beating
> > on
> > > > > > this
> > > > > > > > > thing. I
> > > > > > > > > > > > just took them out, and it's now working. Nothing else
> > has
> > > > > > > changed.
> > > > > > > > > > > printfs
> > > > > > > > > > > > still do not come out in the KMotion console after I
> > re-start
> > > > > > my
> > > > > > > app,
> > > > > > > > > so
> > > > > > > > > > > > there is something still not completely right, but
> > PCComm is
> > > > > > now
> > > > > > > > > working,
> > > > > > > > > > > so
> > > > > > > > > > > > thanks for pointing me in the right direction. I just
> > didn't
> > > > > > even
> > > > > > > > > really
> > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > KMotionCNC....
> > > > > > > > > > > >
> > > > > > > > > > > > What could cause KMotion to be able to talk to the board
> > just
> > > > > > > fine,
> > > > > > > > > but
> > > > > > > > > > > NOT
> > > > > > > > > > > > see printfs? For that matter, when in that state, it
> > does not
> > > > > > see
> > > > > > > DSP
> > > > > > > > > > > tasks
> > > > > > > > > > > > running either, as indficated as there are no green
> > highlights
> > > > > > on
> > > > > > > the
> > > > > > > > > task
> > > > > > > > > > > > IDs next to the editor window. But after re-starting
> > Kmotion,
> > > > > > > without
> > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Tom,
> > > > > > > > > > > > >
> > > > > > > > > > > > > The DSP code is my home function, which works
> > perfectly under
> > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > >
> > > > > > > > > > > > > main()
> > > > > > > > > > > > > {
> > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > }
> > > > > > > > > > > > >
> > > > > > > > > > > > > This gives a different result. The first printf
> > appears every
> > > > > > > time.
> > > > > > > > > The
> > > > > > > > > > > > second one never appears. My app does not crash or
> > behave
> > > > > > > strangely in
> > > > > > > > > any
> > > > > > > > > > > > way that I can see, even if I open and close it several
> > times.
> > > > > > > But, if
> > > > > > > > > I
> > > > > > > > > > > > open KMotion, then open my app, then close it, then
> > re-open it,
> > > > > > > > > KMotion
> > > > > > > > > > > will
> > > > > > > > > > > > still be able to talk to the board, and execute commands
> > from
> > > > > > the
> > > > > > > > > console,
> > > > > > > > > > > > but printfs from the DSP no longer show up in the
> > console
> > > > > > window,
> > > > > > > > > until I
> > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > influencing
> > > > > > > > > the
> > > > > > > > > > > > PCComm stuff. But what could that program be doing that
> > it
> > > > > > > wouldn't be
> > > > > > > > > > > doing
> > > > > > > > > > > > when run under KMotionCNC, where it's always works
> > perfectly??
> > > > > > > > > > > > >
> > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it
> > sounds
> > > > > > > more
> > > > > > > > > like a
> > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC?
> > What
> > > > > > does
> > > > > > > it
> > > > > > > > > do
> > > > > > > > > > > > after it sees the persist var cleared? What if you clear
> > it
> > > > > > from
> > > > > > > the
> > > > > > > > > > > KMotion
> > > > > > > > > > > > Console instead? Otherwise I can look at if you post all
> > the
> > > > > > code.
> > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > TK
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble"
> > <jagboy@>
> > > > > > wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> > > > > > suggestions
> > > > > > > on
> > > > > > > > > how
> > > > > > > > > > > to
> > > > > > > > > > > > proceed. As long as I don't touch Persist[100],
> > everything
> > > > > > works
> > > > > > > just
> > > > > > > > > > > fine.
> > > > > > > > > > > > I can start my app, run programs, exit, connect,
> > disconnect,
> > > > > > and
> > > > > > > it
> > > > > > > > > seems
> > > > > > > > > > > to
> > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side,
> > my
> > > > > > PCComm
> > > > > > > code
> > > > > > > > > > > > correctly processes it, and clears Persist[100], and
> > shortly
> > > > > > after
> > > > > > > > > that,
> > > > > > > > > > > the
> > > > > > > > > > > > board "goes missing", and I get the dialog asking me if
> > I want
> > > > > > to
> > > > > > > run
> > > > > > > > > the
> > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> > > > > > VS2008,
> > > > > > > even
> > > > > > > > > > > though
> > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug"
> > prompt,
> > > > > > it
> > > > > > > opens
> > > > > > > > > > > > VS2008, loads the current source file, and that's it. No
> > > > > > debugger,
> > > > > > > no
> > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing,
> > due to
> > > > > > > having
> > > > > > > > > both
> > > > > > > > > > > > versions installed, but I not only don't know how to fix
> > it, I
> > > > > > am
> > > > > > > > > > > reluctant
> > > > > > > > > > > > to try to get 2008 working in that context, for fear it
> > will
> > > > > > screw
> > > > > > > up
> > > > > > > > > > > 2010,
> > > > > > > > > > > > which is what I generally use. I only installed 2008 to
> > be
> > > > > > able to
> > > > > > > > > build
> > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Anyway, I am convinced it is clearing
> > Persist[100], while
> > > > > > > not
> > > > > > > > > the
> > > > > > > > > > > > actual cause of the problem, is somehow triggering
> > whatever it
> > > > > > is
> > > > > > > that
> > > > > > > > > is
> > > > > > > > > > > > going wrong, but I'm totally at a loss to understand
> > what is
> > > > > > going
> > > > > > > > > wrong,
> > > > > > > > > > > or
> > > > > > > > > > > > how, and have had no success in trying to narrow it
> > down. If I
> > > > > > > comment
> > > > > > > > > out
> > > > > > > > > > > > the one line that clears Persist[100] after a PCComm
> > command,
> > > > > > the
> > > > > > > > > problem
> > > > > > > > > > > > goes away entirely, and everything works perfectly. If I
> > change
> > > > > > > that
> > > > > > > > > one
> > > > > > > > > > > > line to write *any* other location, like 99, or 101, the
> > > > > > failure
> > > > > > > > > > > "signature"
> > > > > > > > > > > > changes - rather than crashing almost immediately after
> > the
> > > > > > > Persist
> > > > > > > > > > > location
> > > > > > > > > > > > is written, the app continues to run normally until I
> > close
> > > > > > it.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > But, if I then re-start the app without first
> > > > > > disconnecting
> > > > > > > and
> > > > > > > > > > > > reconnecting the board, I get the debug dialog again as
> > soon as
> > > > > > > the
> > > > > > > > > new
> > > > > > > > > > > app
> > > > > > > > > > > > instance recognizes the connection is available, and
> > does its
> > > > > > > > > > > KM_Controller
> > > > > > > > > > > > initialization. I've stepped through all the init code
> > and the
> > > > > > > > > > > constructors
> > > > > > > > > > > > on that second start-up, and whatever is going wrong is
> > going
> > > > > > > wrong
> > > > > > > > > AFTER
> > > > > > > > > > > > they have all run, and I don't know how to stop it at a
> > point
> > > > > > that
> > > > > > > > > would
> > > > > > > > > > > > give me any useful information about what is going
> > wrong.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Not surprisingly, if I change the location used
> > for
> > > > > > PComm (I
> > > > > > > > > shifted
> > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the
> > new
> > > > > > > location. So
> > > > > > > > > > > it's
> > > > > > > > > > > > not the specific location that's at issue, it has to be
> > > > > > something
> > > > > > > > > > > connected
> > > > > > > > > > > > with that functionality. But we know the DSP side works
> > fine,
> > > > > > and
> > > > > > > the
> > > > > > > > > PC
> > > > > > > > > > > > side isn't actually *doing* anything, other than writing
> > that
> > > > > > one
> > > > > > > > > word. So
> > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've double-checked and all my KM_Controller
> > accesses are
> > > > > > > > > surrounded
> > > > > > > > > > > > with locks, and I'm not doing anything that requires
> > grabbing
> > > > > > the
> > > > > > > > > token
> > > > > > > > > > > (the
> > > > > > > > > > > > functions for doing Gather operations do use the token,
> > but
> > > > > > those
> > > > > > > are
> > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > At the point where it's crashing, there are three
> > threads
> > > > > > > > > running:
> > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > 2) A thread running the WCF server for the
> > toolpath
> > > > > > display
> > > > > > > > > (which
> > > > > > > > > > > is
> > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> > > > > > updates
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The app thread also has one Timer running, at a
> > 100mSec
> > > > > > > rate,
> > > > > > > > > mostly
> > > > > > > > > > > > for periodically testing the connection, and updating
> > the
> > > > > > > "connected"
> > > > > > > > > LED
> > > > > > > > > > > in
> > > > > > > > > > > > the GUI, and showing me the GUI state through a set of
> > > > > > on-screen
> > > > > > > > > > > checkboxes.
> > > > > > > > > > > > This thread is the one that calls the PCComm handler.
> > All Timer
> > > > > > > > > methods
> > > > > > > > > > > are
> > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my
> > code if
> > > > > > > that
> > > > > > > > > would
> > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3653 |
From: himykabibble |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Here is where my problem lies:
KM_Controller.Interpreter.ReadCurInterpreterPosition() and KM_Controller.Interpreter.ReadCurMachinePosition() are taking an average of 20 mSec each. For four axes, that's about 80mSec per update. I also found a bug in my code that was causing it to do frequent MainStatus reads, but I've commented that code out for now. My display update code takes, in average, less than a mSec to run. It is the dotNet calls that are slowing me down. If I comment out the one line containing the above call, my update rate jumps from ~4/second up to ~12/second. ALL other code is still running. Most other dotNet calls, seem to average on the order of 2-3mSec. Are the above calls not the same ones Brads apps use to get position? Why is it so slow for me?
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> BTW - I am no longer seeing ANY hangs, even when I hammer it with printfs and PCComms.
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> >
> > Brad,
> >
> > I'm not convinced the slowness I'm seeing is associated with any particular feature. It seems pretty random. I did find a bug in my StringGather that caused it to be transferring more data than it should have, but the overall update timing is slow, and quite variable, so I think it's either too much traffic, and/or a lot of blocking going on. I'm going to measure what the update loop time is. It's certainly not close to the 10/second it should be.
> >
> > Is there any problem with asynchronous reads of GUI controls and other objects associated with the GUI thread?
> >
> > I'd be curious what kind of update rate you see if you run the following on the DSP with a dotNet app. I see the messages coming about every 1/4 second or so, while under KMotion it looks like about 10/second, as it should be.
> >
> > while(1)
> > {
> > int i;
> > printf )"1\n");
> > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > printf )"2\n");
> > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > printf )"3\n");
> > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > }
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > >
> > > ServiceConsole was not fully implemented, I wonder if that message pump is
> > > getting clogged.
> > >
> > >
> > >
> > > It is now implemented, as I saw it was being used in KMotionCNC.
> > >
> > >
> > >
> > > Not sure if that is a/the issue though.
> > >
> > >
> > >
> > > -Brad Murry
> > >
> > >
> > >
> > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > Behalf Of himykabibble
> > > Sent: Tuesday, January 31, 2012 10:00 PM
> > > To: DynoMotion@yahoogroups.com
> > > Subject: [DynoMotion] Re: Need Some Ideas....
> > >
> > >
> > >
> > >
> > >
> > > Tom/Brad,
> > >
> > > Earlier I was again seeing hangs associated with PCComm and/or Console
> > > messages. I added a message queue for the console messages, and it seems to
> > > be working solidly again, albeit slow. The GUI will sometimes become
> > > unresponsive for several seconds (up to 15 at times), then come back to
> > > life. Even when it's working, it seems sluggish to me. As I mentioned, the
> > > DROs seem to be updating only about 2-3 times per second. If I run a DSP
> > > program that does a printf every 2000 time slices, the messages come out at
> > > irregular intervals. If I send the messages through PCComm, both the average
> > > time, and the irregularity are much greater, with the bulk of time being
> > > spent doing the String gathers, which sometimes take as much as 2 or 3
> > > seconds to complete, for a message that is only about a dozen characters. I
> > > have to assume I still have some blocking problems. Any suggestions how to
> > > find them?
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > "himykabibble" <jagboy@> wrote:
> > > >
> > > > What I'm seeing right now is VERY long times to do the gather in PCComm to
> > > retrieve a short String - sometimes on the order of several seconds to
> > > retrieve a String that is perhaps a dozen characters. printfs are coming
> > > through reliably, and quickly. It seems to me like most operations that are
> > > talking to the board are taking an inordinately long time to complete,
> > > slowing everything down. I have no doubts this is a threading issue, but I
> > > don't know what, and VS2010 seems to provide no support for examining
> > > threads...
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > "himykabibble" <jagboy@> wrote:
> > > > >
> > > > > Unfortunately, my celebration turns out to be a bit premature. My
> > > deadlocks are back, after making a few minor changes.... I also noticed
> > > today while running on the machine that DRO updates are still very slow - on
> > > the order to 2-3 updates/seconds. I suspect there's a lot of waiting going
> > > on somewhere in there.
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > , Andrew Ford <ahford@> wrote:
> > > > > >
> > > > > > I'm able to get the same hang in Kmotion with a printf every second or
> > > so.
> > > > > > I didn't take too close a look at it in the debugger but it looks like
> > > a
> > > > > > deadlock. I could take a closer look again tonight.
> > > > > >
> > > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> > > > > >
> > > > > > > **
> > > > > > >
> > > > > > >
> > > > > > > Hi Ray,
> > > > > > >
> > > > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an
> > > App
> > > > > > > does a ReadLine from KFLOP the KMotionServer will do a read from
> > > KFLOP and
> > > > > > > may get back the unsolicited message instead of the expected
> > > response. In
> > > > > > > that case the unsolicited message received will be sent to the App
> > > via the
> > > > > > > ConsoleCallback and then another read will be performed to get the
> > > expected
> > > > > > > response.
> > > > > > >
> > > > > > > So from your description it seems like the crash is somehow being
> > > caused
> > > > > > > by the ConsoleCallback possibly due to a bug in the .Net interface
> > > or
> > > > > > > because the Console is doing something bad in your GUI. Maybe change
> > > the
> > > > > > > ConsoleCallback to just discard the message to help narrow things
> > > down.
> > > > > > >
> > > > > > > It isn't clear to me if the crash you report having in the
> > > MarshalPost is
> > > > > > > before the call or after.
> > > > > > >
> > > > > > > Regards
> > > > > > > TK
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > *From:* himykabibble <jagboy@>
> > > > > > > *To:* DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > *Sent:* Monday, January 30, 2012 4:14 PM
> > > > > > >
> > > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > > > > > >
> > > > > > >
> > > > > > > Brad,
> > > > > > >
> > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code,
> > > > > > > PCComm works, as does MDI from the DSP (and I assume most of the
> > > other
> > > > > > > functions, though I haven't tested them all yet). (Mind you, that
> > > same DSP
> > > > > > > code, printfs and all, works perfectly under KMotionCNC...) PCComm
> > > was
> > > > > > > "fixed" by getting rid of the printfs in the DSP code. Put the
> > > printfs
> > > > > > > back, and it starts locking up again (in CheckIsReady() before, but
> > > now in
> > > > > > > MarshalPost within WriteLineReadLine - At least it's a
> > > dead-consistent
> > > > > > > failure!). Console messages also work fine, as long as there are NO
> > > printfs
> > > > > > > in the DSP code.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote:
> > > > > > > >
> > > > > > > > Ray,
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > I thought the main issue we were working on was the printf's/PComm
> > > > > > > issues in
> > > > > > > > your user programs, has that situation improved at all?
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Good that your MDI code works though.
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > -Brad
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > From: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > > > > Behalf Of himykabibble
> > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > To: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI
> > > problem,
> > > > > > > but I
> > > > > > > > still get the hangs in CheckIsRead() when I have the console
> > > callback
> > > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > ,
> > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just
> > > needed to
> > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to
> > > your
> > > > > > > GUI
> > > > > > > > components, but in my case an HTML button is being clicked,
> > > handled by
> > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the
> > > printf
> > > > > > > is
> > > > > > > > using some [STAThread ] component..
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > So Ray, surround your calls in an invoke clause as well and see
> > > if it
> > > > > > > > improves.
> > > > > > > > >
> > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > >
> > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > {
> > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > {
> > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > }
> > > > > > > > > else
> > > > > > > > > {
> > > > > > > > > action();
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > > >
> > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > {
> > > > > > > > > //Your existing code inside here
> > > > > > > > > }
> > > > > > > > > ));
> > > > > > > > >
> > > > > > > > > Let me know if this helps.
> > > > > > > > >
> > > > > > > > > -Brad Murry
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > ,
> > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > > Hello Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > > problematic
> > > > > > > > > > procedures inside a console app.. Only crashes my winforms
> > > > > > > browserapp.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > ]
> > > > > > > > On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > >
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > I wired in the console message handler, and I now get frequent
> > > > > > > lock-ups.
> > > > > > > > My
> > > > > > > > > > handler does nothing more than one line of code that stuffs
> > > the
> > > > > > > String
> > > > > > > > > > argument into a TextBox. With that one line commented out, all
> > > is
> > > > > > > good.
> > > > > > > > But
> > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the
> > > app
> > > > > > > just
> > > > > > > > locks
> > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops
> > > responding
> > > > > > > > > > entirely. The callback does work as it should, until the app
> > > locks
> > > > > > > up.
> > > > > > > > Is
> > > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > Well it makes me happy to see someone besides me having
> > > strange
> > > > > > > things
> > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your
> > > problem
> > > > > > > it
> > > > > > > > will
> > > > > > > > > > fix mine as well.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works
> > > just
> > > > > > > fine,
> > > > > > > > it
> > > > > > > > > > only
> > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user
> > > buttons. If
> > > > > > > you
> > > > > > > > look
> > > > > > > > > > at
> > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the
> > > button
> > > > > > > > commands as
> > > > > > > > > > if
> > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Still, it does not explain why it works for me and not you
> > > using
> > > > > > > the
> > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Then again, I am not using any PComm in my test
> > > prog(print.c).
> > > > > > > I'll
> > > > > > > > try
> > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > No, I do not have the message event hooked up in my app.
> > > > > > > (Actually,
> > > > > > > > > > didn't
> > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > >
> > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > > InvokeAction a
> > > > > > > > > > > > better way to do it?
> > > > > > > > > > > >
> > > > > > > > > > > > I've just run into a new problem as well. Two steps
> > > forward, one
> > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now
> > > are not.
> > > > > > > > > > Non-motion
> > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> > > > > > > commands
> > > > > > > > never
> > > > > > > > > > > > issue a Completed callback. The move IS completed, I get
> > > the
> > > > > > > status
> > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by
> > > hitting
> > > > > > > my
> > > > > > > > > > E-stop
> > > > > > > > > > > > button, or re-starting the App, THEN I get the completed
> > > > > > > callback.
> > > > > > > > So
> > > > > > > > > > > > something is blocking something there as well. This was
> > > working
> > > > > > > fine
> > > > > > > > > > until I
> > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > I am wondering if there are some .net memory sharing
> > > issues
> > > > > > > going
> > > > > > > > on
> > > > > > > > > > here.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > I just set one of my user buttons to fire off the
> > > print.c
> > > > > > > program
> > > > > > > > and
> > > > > > > > > > I
> > > > > > > > > > > > get
> > > > > > > > > > > > > the same result.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > I do, and I get the Hello, World message followed by an
> > > > > > > immediate
> > > > > > > > > > crash.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > It is interesting to note that we get the print messages
> > > just
> > > > > > > fine
> > > > > > > > > > from
> > > > > > > > > > > > the
> > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > So I tried this code in my button event handler as a
> > > quick and
> > > > > > > > dirty
> > > > > > > > > > > > test::
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot +
> > > @"\C
> > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > >
> > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > >
> > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > >
> > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no
> > > crashes).
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > I looks like InvokeAction with printf's are doing
> > > something
> > > > > > > screwy
> > > > > > > > > > here.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Ray- Are you invoking your cprogram via
> > > > > > > Interpreter.InvokeAction
> > > > > > > > as
> > > > > > > > > > well?
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > On
> > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Tom,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I know this is a stupid question, but is there some
> > > > > > > interaction or
> > > > > > > > > > shared
> > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and
> > > printfs? I
> > > > > > > > had
> > > > > > > > > > some
> > > > > > > > > > > > > printfs in the Home code that I had put in while beating
> > > on
> > > > > > > this
> > > > > > > > > > thing. I
> > > > > > > > > > > > > just took them out, and it's now working. Nothing else
> > > has
> > > > > > > > changed.
> > > > > > > > > > > > printfs
> > > > > > > > > > > > > still do not come out in the KMotion console after I
> > > re-start
> > > > > > > my
> > > > > > > > app,
> > > > > > > > > > so
> > > > > > > > > > > > > there is something still not completely right, but
> > > PCComm is
> > > > > > > now
> > > > > > > > > > working,
> > > > > > > > > > > > so
> > > > > > > > > > > > > thanks for pointing me in the right direction. I just
> > > didn't
> > > > > > > even
> > > > > > > > > > really
> > > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > > KMotionCNC....
> > > > > > > > > > > > >
> > > > > > > > > > > > > What could cause KMotion to be able to talk to the board
> > > just
> > > > > > > > fine,
> > > > > > > > > > but
> > > > > > > > > > > > NOT
> > > > > > > > > > > > > see printfs? For that matter, when in that state, it
> > > does not
> > > > > > > see
> > > > > > > > DSP
> > > > > > > > > > > > tasks
> > > > > > > > > > > > > running either, as indficated as there are no green
> > > highlights
> > > > > > > on
> > > > > > > > the
> > > > > > > > > > task
> > > > > > > > > > > > > IDs next to the editor window. But after re-starting
> > > Kmotion,
> > > > > > > > without
> > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > The DSP code is my home function, which works
> > > perfectly under
> > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > {
> > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > }
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > This gives a different result. The first printf
> > > appears every
> > > > > > > > time.
> > > > > > > > > > The
> > > > > > > > > > > > > second one never appears. My app does not crash or
> > > behave
> > > > > > > > strangely in
> > > > > > > > > > any
> > > > > > > > > > > > > way that I can see, even if I open and close it several
> > > times.
> > > > > > > > But, if
> > > > > > > > > > I
> > > > > > > > > > > > > open KMotion, then open my app, then close it, then
> > > re-open it,
> > > > > > > > > > KMotion
> > > > > > > > > > > > will
> > > > > > > > > > > > > still be able to talk to the board, and execute commands
> > > from
> > > > > > > the
> > > > > > > > > > console,
> > > > > > > > > > > > > but printfs from the DSP no longer show up in the
> > > console
> > > > > > > window,
> > > > > > > > > > until I
> > > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > > influencing
> > > > > > > > > > the
> > > > > > > > > > > > > PCComm stuff. But what could that program be doing that
> > > it
> > > > > > > > wouldn't be
> > > > > > > > > > > > doing
> > > > > > > > > > > > > when run under KMotionCNC, where it's always works
> > > perfectly??
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it
> > > sounds
> > > > > > > > more
> > > > > > > > > > like a
> > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC?
> > > What
> > > > > > > does
> > > > > > > > it
> > > > > > > > > > do
> > > > > > > > > > > > > after it sees the persist var cleared? What if you clear
> > > it
> > > > > > > from
> > > > > > > > the
> > > > > > > > > > > > KMotion
> > > > > > > > > > > > > Console instead? Otherwise I can look at if you post all
> > > the
> > > > > > > code.
> > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble"
> > > <jagboy@>
> > > > > > > wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> > > > > > > suggestions
> > > > > > > > on
> > > > > > > > > > how
> > > > > > > > > > > > to
> > > > > > > > > > > > > proceed. As long as I don't touch Persist[100],
> > > everything
> > > > > > > works
> > > > > > > > just
> > > > > > > > > > > > fine.
> > > > > > > > > > > > > I can start my app, run programs, exit, connect,
> > > disconnect,
> > > > > > > and
> > > > > > > > it
> > > > > > > > > > seems
> > > > > > > > > > > > to
> > > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side,
> > > my
> > > > > > > PCComm
> > > > > > > > code
> > > > > > > > > > > > > correctly processes it, and clears Persist[100], and
> > > shortly
> > > > > > > after
> > > > > > > > > > that,
> > > > > > > > > > > > the
> > > > > > > > > > > > > board "goes missing", and I get the dialog asking me if
> > > I want
> > > > > > > to
> > > > > > > > run
> > > > > > > > > > the
> > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> > > > > > > VS2008,
> > > > > > > > even
> > > > > > > > > > > > though
> > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug"
> > > prompt,
> > > > > > > it
> > > > > > > > opens
> > > > > > > > > > > > > VS2008, loads the current source file, and that's it. No
> > > > > > > debugger,
> > > > > > > > no
> > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing,
> > > due to
> > > > > > > > having
> > > > > > > > > > both
> > > > > > > > > > > > > versions installed, but I not only don't know how to fix
> > > it, I
> > > > > > > am
> > > > > > > > > > > > reluctant
> > > > > > > > > > > > > to try to get 2008 working in that context, for fear it
> > > will
> > > > > > > screw
> > > > > > > > up
> > > > > > > > > > > > 2010,
> > > > > > > > > > > > > which is what I generally use. I only installed 2008 to
> > > be
> > > > > > > able to
> > > > > > > > > > build
> > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing
> > > Persist[100], while
> > > > > > > > not
> > > > > > > > > > the
> > > > > > > > > > > > > actual cause of the problem, is somehow triggering
> > > whatever it
> > > > > > > is
> > > > > > > > that
> > > > > > > > > > is
> > > > > > > > > > > > > going wrong, but I'm totally at a loss to understand
> > > what is
> > > > > > > going
> > > > > > > > > > wrong,
> > > > > > > > > > > > or
> > > > > > > > > > > > > how, and have had no success in trying to narrow it
> > > down. If I
> > > > > > > > comment
> > > > > > > > > > out
> > > > > > > > > > > > > the one line that clears Persist[100] after a PCComm
> > > command,
> > > > > > > the
> > > > > > > > > > problem
> > > > > > > > > > > > > goes away entirely, and everything works perfectly. If I
> > > change
> > > > > > > > that
> > > > > > > > > > one
> > > > > > > > > > > > > line to write *any* other location, like 99, or 101, the
> > > > > > > failure
> > > > > > > > > > > > "signature"
> > > > > > > > > > > > > changes - rather than crashing almost immediately after
> > > the
> > > > > > > > Persist
> > > > > > > > > > > > location
> > > > > > > > > > > > > is written, the app continues to run normally until I
> > > close
> > > > > > > it.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > But, if I then re-start the app without first
> > > > > > > disconnecting
> > > > > > > > and
> > > > > > > > > > > > > reconnecting the board, I get the debug dialog again as
> > > soon as
> > > > > > > > the
> > > > > > > > > > new
> > > > > > > > > > > > app
> > > > > > > > > > > > > instance recognizes the connection is available, and
> > > does its
> > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > initialization. I've stepped through all the init code
> > > and the
> > > > > > > > > > > > constructors
> > > > > > > > > > > > > on that second start-up, and whatever is going wrong is
> > > going
> > > > > > > > wrong
> > > > > > > > > > AFTER
> > > > > > > > > > > > > they have all run, and I don't know how to stop it at a
> > > point
> > > > > > > that
> > > > > > > > > > would
> > > > > > > > > > > > > give me any useful information about what is going
> > > wrong.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Not surprisingly, if I change the location used
> > > for
> > > > > > > PComm (I
> > > > > > > > > > shifted
> > > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the
> > > new
> > > > > > > > location. So
> > > > > > > > > > > > it's
> > > > > > > > > > > > > not the specific location that's at issue, it has to be
> > > > > > > something
> > > > > > > > > > > > connected
> > > > > > > > > > > > > with that functionality. But we know the DSP side works
> > > fine,
> > > > > > > and
> > > > > > > > the
> > > > > > > > > > PC
> > > > > > > > > > > > > side isn't actually *doing* anything, other than writing
> > > that
> > > > > > > one
> > > > > > > > > > word. So
> > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller
> > > accesses are
> > > > > > > > > > surrounded
> > > > > > > > > > > > > with locks, and I'm not doing anything that requires
> > > grabbing
> > > > > > > the
> > > > > > > > > > token
> > > > > > > > > > > > (the
> > > > > > > > > > > > > functions for doing Gather operations do use the token,
> > > but
> > > > > > > those
> > > > > > > > are
> > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > At the point where it's crashing, there are three
> > > threads
> > > > > > > > > > running:
> > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > 2) A thread running the WCF server for the
> > > toolpath
> > > > > > > display
> > > > > > > > > > (which
> > > > > > > > > > > > is
> > > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> > > > > > > updates
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > The app thread also has one Timer running, at a
> > > 100mSec
> > > > > > > > rate,
> > > > > > > > > > mostly
> > > > > > > > > > > > > for periodically testing the connection, and updating
> > > the
> > > > > > > > "connected"
> > > > > > > > > > LED
> > > > > > > > > > > > in
> > > > > > > > > > > > > the GUI, and showing me the GUI state through a set of
> > > > > > > on-screen
> > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > This thread is the one that calls the PCComm handler.
> > > All Timer
> > > > > > > > > > methods
> > > > > > > > > > > > are
> > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my
> > > code if
> > > > > > > > that
> > > > > > > > > > would
> > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3654 |
From: himykabibble |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
I was calling KM_Controller.Interpreter.ReadCurInterpreterPosition() for EACH axis - not very efficient. So I now call it once per update, and I'm now seeing 8-10 updates/second - not too bad, and it is visually MUCH better. Still seems to me 20mSec is a very long time for that call, no?
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote:
>
> Here is where my problem lies:
>
> KM_Controller.Interpreter.ReadCurInterpreterPosition() and KM_Controller.Interpreter.ReadCurMachinePosition() are taking an average of 20 mSec each. For four axes, that's about 80mSec per update. I also found a bug in my code that was causing it to do frequent MainStatus reads, but I've commented that code out for now. My display update code takes, in average, less than a mSec to run. It is the dotNet calls that are slowing me down. If I comment out the one line containing the above call, my update rate jumps from ~4/second up to ~12/second. ALL other code is still running. Most other dotNet calls, seem to average on the order of 2-3mSec. Are the above calls not the same ones Brads apps use to get position? Why is it so slow for me?
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> >
> > BTW - I am no longer seeing ANY hangs, even when I hammer it with printfs and PCComms.
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote:
> > >
> > > Brad,
> > >
> > > I'm not convinced the slowness I'm seeing is associated with any particular feature. It seems pretty random. I did find a bug in my StringGather that caused it to be transferring more data than it should have, but the overall update timing is slow, and quite variable, so I think it's either too much traffic, and/or a lot of blocking going on. I'm going to measure what the update loop time is. It's certainly not close to the 10/second it should be.
> > >
> > > Is there any problem with asynchronous reads of GUI controls and other objects associated with the GUI thread?
> > >
> > > I'd be curious what kind of update rate you see if you run the following on the DSP with a dotNet app. I see the messages coming about every 1/4 second or so, while under KMotion it looks like about 10/second, as it should be.
> > >
> > > while(1)
> > > {
> > > int i;
> > > printf )"1\n");
> > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > printf )"2\n");
> > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > printf )"3\n");
> > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > }
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> > > >
> > > > ServiceConsole was not fully implemented, I wonder if that message pump is
> > > > getting clogged.
> > > >
> > > >
> > > >
> > > > It is now implemented, as I saw it was being used in KMotionCNC.
> > > >
> > > >
> > > >
> > > > Not sure if that is a/the issue though.
> > > >
> > > >
> > > >
> > > > -Brad Murry
> > > >
> > > >
> > > >
> > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > > > Behalf Of himykabibble
> > > > Sent: Tuesday, January 31, 2012 10:00 PM
> > > > To: DynoMotion@yahoogroups.com
> > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Tom/Brad,
> > > >
> > > > Earlier I was again seeing hangs associated with PCComm and/or Console
> > > > messages. I added a message queue for the console messages, and it seems to
> > > > be working solidly again, albeit slow. The GUI will sometimes become
> > > > unresponsive for several seconds (up to 15 at times), then come back to
> > > > life. Even when it's working, it seems sluggish to me. As I mentioned, the
> > > > DROs seem to be updating only about 2-3 times per second. If I run a DSP
> > > > program that does a printf every 2000 time slices, the messages come out at
> > > > irregular intervals. If I send the messages through PCComm, both the average
> > > > time, and the irregularity are much greater, with the bulk of time being
> > > > spent doing the String gathers, which sometimes take as much as 2 or 3
> > > > seconds to complete, for a message that is only about a dozen characters. I
> > > > have to assume I still have some blocking problems. Any suggestions how to
> > > > find them?
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > "himykabibble" <jagboy@> wrote:
> > > > >
> > > > > What I'm seeing right now is VERY long times to do the gather in PCComm to
> > > > retrieve a short String - sometimes on the order of several seconds to
> > > > retrieve a String that is perhaps a dozen characters. printfs are coming
> > > > through reliably, and quickly. It seems to me like most operations that are
> > > > talking to the board are taking an inordinately long time to complete,
> > > > slowing everything down. I have no doubts this is a threading issue, but I
> > > > don't know what, and VS2010 seems to provide no support for examining
> > > > threads...
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > > > "himykabibble" <jagboy@> wrote:
> > > > > >
> > > > > > Unfortunately, my celebration turns out to be a bit premature. My
> > > > deadlocks are back, after making a few minor changes.... I also noticed
> > > > today while running on the machine that DRO updates are still very slow - on
> > > > the order to 2-3 updates/seconds. I suspect there's a lot of waiting going
> > > > on somewhere in there.
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > , Andrew Ford <ahford@> wrote:
> > > > > > >
> > > > > > > I'm able to get the same hang in Kmotion with a printf every second or
> > > > so.
> > > > > > > I didn't take too close a look at it in the debugger but it looks like
> > > > a
> > > > > > > deadlock. I could take a closer look again tonight.
> > > > > > >
> > > > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> > > > > > >
> > > > > > > > **
> > > > > > > >
> > > > > > > >
> > > > > > > > Hi Ray,
> > > > > > > >
> > > > > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an
> > > > App
> > > > > > > > does a ReadLine from KFLOP the KMotionServer will do a read from
> > > > KFLOP and
> > > > > > > > may get back the unsolicited message instead of the expected
> > > > response. In
> > > > > > > > that case the unsolicited message received will be sent to the App
> > > > via the
> > > > > > > > ConsoleCallback and then another read will be performed to get the
> > > > expected
> > > > > > > > response.
> > > > > > > >
> > > > > > > > So from your description it seems like the crash is somehow being
> > > > caused
> > > > > > > > by the ConsoleCallback possibly due to a bug in the .Net interface
> > > > or
> > > > > > > > because the Console is doing something bad in your GUI. Maybe change
> > > > the
> > > > > > > > ConsoleCallback to just discard the message to help narrow things
> > > > down.
> > > > > > > >
> > > > > > > > It isn't clear to me if the crash you report having in the
> > > > MarshalPost is
> > > > > > > > before the call or after.
> > > > > > > >
> > > > > > > > Regards
> > > > > > > > TK
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > *From:* himykabibble <jagboy@>
> > > > > > > > *To:* DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > *Sent:* Monday, January 30, 2012 4:14 PM
> > > > > > > >
> > > > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > > > > > > >
> > > > > > > >
> > > > > > > > Brad,
> > > > > > > >
> > > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code,
> > > > > > > > PCComm works, as does MDI from the DSP (and I assume most of the
> > > > other
> > > > > > > > functions, though I haven't tested them all yet). (Mind you, that
> > > > same DSP
> > > > > > > > code, printfs and all, works perfectly under KMotionCNC...) PCComm
> > > > was
> > > > > > > > "fixed" by getting rid of the printfs in the DSP code. Put the
> > > > printfs
> > > > > > > > back, and it starts locking up again (in CheckIsReady() before, but
> > > > now in
> > > > > > > > MarshalPost within WriteLineReadLine - At least it's a
> > > > dead-consistent
> > > > > > > > failure!). Console messages also work fine, as long as there are NO
> > > > printfs
> > > > > > > > in the DSP code.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote:
> > > > > > > > >
> > > > > > > > > Ray,
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > I thought the main issue we were working on was the printf's/PComm
> > > > > > > > issues in
> > > > > > > > > your user programs, has that situation improved at all?
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Good that your MDI code works though.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > -Brad
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > > > > > Behalf Of himykabibble
> > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI
> > > > problem,
> > > > > > > > but I
> > > > > > > > > still get the hangs in CheckIsRead() when I have the console
> > > > callback
> > > > > > > > > updating the TextBox, even though it is now also being invoked.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > ,
> > > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just
> > > > needed to
> > > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to
> > > > your
> > > > > > > > GUI
> > > > > > > > > components, but in my case an HTML button is being clicked,
> > > > handled by
> > > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the
> > > > printf
> > > > > > > > is
> > > > > > > > > using some [STAThread ] component..
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see
> > > > if it
> > > > > > > > > improves.
> > > > > > > > > >
> > > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > > >
> > > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > > {
> > > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > > {
> > > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > > }
> > > > > > > > > > else
> > > > > > > > > > {
> > > > > > > > > > action();
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. ::
> > > > > > > > > >
> > > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > > {
> > > > > > > > > > //Your existing code inside here
> > > > > > > > > > }
> > > > > > > > > > ));
> > > > > > > > > >
> > > > > > > > > > Let me know if this helps.
> > > > > > > > > >
> > > > > > > > > > -Brad Murry
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > ,
> > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > > Hello Ray,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > In related news, I have no issues running any of my previously
> > > > > > > > > problematic
> > > > > > > > > > > procedures inside a console app.. Only crashes my winforms
> > > > > > > > browserapp.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > ]
> > > > > > > > > On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > >
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > I wired in the console message handler, and I now get frequent
> > > > > > > > lock-ups.
> > > > > > > > > My
> > > > > > > > > > > handler does nothing more than one line of code that stuffs
> > > > the
> > > > > > > > String
> > > > > > > > > > > argument into a TextBox. With that one line commented out, all
> > > > is
> > > > > > > > good.
> > > > > > > > > But
> > > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the
> > > > app
> > > > > > > > just
> > > > > > > > > locks
> > > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops
> > > > responding
> > > > > > > > > > > entirely. The callback does work as it should, until the app
> > > > locks
> > > > > > > > up.
> > > > > > > > > Is
> > > > > > > > > > > this a threading thing? Nobody else writes to that TextBox.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > Well it makes me happy to see someone besides me having
> > > > strange
> > > > > > > > things
> > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your
> > > > problem
> > > > > > > > it
> > > > > > > > > will
> > > > > > > > > > > fix mine as well.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works
> > > > just
> > > > > > > > fine,
> > > > > > > > > it
> > > > > > > > > > > only
> > > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user
> > > > buttons. If
> > > > > > > > you
> > > > > > > > > look
> > > > > > > > > > > at
> > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the
> > > > button
> > > > > > > > > commands as
> > > > > > > > > > > if
> > > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Still, it does not explain why it works for me and not you
> > > > using
> > > > > > > > the
> > > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Then again, I am not using any PComm in my test
> > > > prog(print.c).
> > > > > > > > I'll
> > > > > > > > > try
> > > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > -Brad
> > > > > > > > > > > > >
> > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > On
> > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > No, I do not have the message event hooked up in my app.
> > > > > > > > (Actually,
> > > > > > > > > > > didn't
> > > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > > >
> > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is
> > > > > > > > > InvokeAction a
> > > > > > > > > > > > > better way to do it?
> > > > > > > > > > > > >
> > > > > > > > > > > > > I've just run into a new problem as well. Two steps
> > > > forward, one
> > > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now
> > > > are not.
> > > > > > > > > > > Non-motion
> > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion
> > > > > > > > commands
> > > > > > > > > never
> > > > > > > > > > > > > issue a Completed callback. The move IS completed, I get
> > > > the
> > > > > > > > status
> > > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by
> > > > hitting
> > > > > > > > my
> > > > > > > > > > > E-stop
> > > > > > > > > > > > > button, or re-starting the App, THEN I get the completed
> > > > > > > > callback.
> > > > > > > > > So
> > > > > > > > > > > > > something is blocking something there as well. This was
> > > > working
> > > > > > > > fine
> > > > > > > > > > > until I
> > > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I am wondering if there are some .net memory sharing
> > > > issues
> > > > > > > > going
> > > > > > > > > on
> > > > > > > > > > > here.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I just set one of my user buttons to fire off the
> > > > print.c
> > > > > > > > program
> > > > > > > > > and
> > > > > > > > > > > I
> > > > > > > > > > > > > get
> > > > > > > > > > > > > > the same result.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an
> > > > > > > > immediate
> > > > > > > > > > > crash.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > It is interesting to note that we get the print messages
> > > > just
> > > > > > > > fine
> > > > > > > > > > > from
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > So I tried this code in my button event handler as a
> > > > quick and
> > > > > > > > > dirty
> > > > > > > > > > > > > test::
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot +
> > > > @"\C
> > > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no
> > > > crashes).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing
> > > > something
> > > > > > > > screwy
> > > > > > > > > > > here.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Ray- Are you invoking your cprogram via
> > > > > > > > Interpreter.InvokeAction
> > > > > > > > > as
> > > > > > > > > > > well?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > On
> > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I know this is a stupid question, but is there some
> > > > > > > > interaction or
> > > > > > > > > > > shared
> > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and
> > > > printfs? I
> > > > > > > > > had
> > > > > > > > > > > some
> > > > > > > > > > > > > > printfs in the Home code that I had put in while beating
> > > > on
> > > > > > > > this
> > > > > > > > > > > thing. I
> > > > > > > > > > > > > > just took them out, and it's now working. Nothing else
> > > > has
> > > > > > > > > changed.
> > > > > > > > > > > > > printfs
> > > > > > > > > > > > > > still do not come out in the KMotion console after I
> > > > re-start
> > > > > > > > my
> > > > > > > > > app,
> > > > > > > > > > > so
> > > > > > > > > > > > > > there is something still not completely right, but
> > > > PCComm is
> > > > > > > > now
> > > > > > > > > > > working,
> > > > > > > > > > > > > so
> > > > > > > > > > > > > > thanks for pointing me in the right direction. I just
> > > > didn't
> > > > > > > > even
> > > > > > > > > > > really
> > > > > > > > > > > > > > consider the DSP Code, because it's always worked under
> > > > > > > > > KMotionCNC....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board
> > > > just
> > > > > > > > > fine,
> > > > > > > > > > > but
> > > > > > > > > > > > > NOT
> > > > > > > > > > > > > > see printfs? For that matter, when in that state, it
> > > > does not
> > > > > > > > see
> > > > > > > > > DSP
> > > > > > > > > > > > > tasks
> > > > > > > > > > > > > > running either, as indficated as there are no green
> > > > highlights
> > > > > > > > on
> > > > > > > > > the
> > > > > > > > > > > task
> > > > > > > > > > > > > > IDs next to the editor window. But after re-starting
> > > > Kmotion,
> > > > > > > > > without
> > > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > The DSP code is my home function, which works
> > > > perfectly under
> > > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > > But, just to be sure, I went to a three line program:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > This gives a different result. The first printf
> > > > appears every
> > > > > > > > > time.
> > > > > > > > > > > The
> > > > > > > > > > > > > > second one never appears. My app does not crash or
> > > > behave
> > > > > > > > > strangely in
> > > > > > > > > > > any
> > > > > > > > > > > > > > way that I can see, even if I open and close it several
> > > > times.
> > > > > > > > > But, if
> > > > > > > > > > > I
> > > > > > > > > > > > > > open KMotion, then open my app, then close it, then
> > > > re-open it,
> > > > > > > > > > > KMotion
> > > > > > > > > > > > > will
> > > > > > > > > > > > > > still be able to talk to the board, and execute commands
> > > > from
> > > > > > > > the
> > > > > > > > > > > console,
> > > > > > > > > > > > > > but printfs from the DSP no longer show up in the
> > > > console
> > > > > > > > window,
> > > > > > > > > > > until I
> > > > > > > > > > > > > > close then re-open KMotion. Does that make any sense?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I will try to narrow down what in the Home program is
> > > > > > > > > influencing
> > > > > > > > > > > the
> > > > > > > > > > > > > > PCComm stuff. But what could that program be doing that
> > > > it
> > > > > > > > > wouldn't be
> > > > > > > > > > > > > doing
> > > > > > > > > > > > > > when run under KMotionCNC, where it's always works
> > > > perfectly??
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it
> > > > sounds
> > > > > > > > > more
> > > > > > > > > > > like a
> > > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to the PC?
> > > > What
> > > > > > > > does
> > > > > > > > > it
> > > > > > > > > > > do
> > > > > > > > > > > > > > after it sees the persist var cleared? What if you clear
> > > > it
> > > > > > > > from
> > > > > > > > > the
> > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > Console instead? Otherwise I can look at if you post all
> > > > the
> > > > > > > > code.
> > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble"
> > > > <jagboy@>
> > > > > > > > wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some
> > > > > > > > suggestions
> > > > > > > > > on
> > > > > > > > > > > how
> > > > > > > > > > > > > to
> > > > > > > > > > > > > > proceed. As long as I don't touch Persist[100],
> > > > everything
> > > > > > > > works
> > > > > > > > > just
> > > > > > > > > > > > > fine.
> > > > > > > > > > > > > > I can start my app, run programs, exit, connect,
> > > > disconnect,
> > > > > > > > and
> > > > > > > > > it
> > > > > > > > > > > seems
> > > > > > > > > > > > > to
> > > > > > > > > > > > > > work quite reliably. But if I do a MSG on the DSP side,
> > > > my
> > > > > > > > PCComm
> > > > > > > > > code
> > > > > > > > > > > > > > correctly processes it, and clears Persist[100], and
> > > > shortly
> > > > > > > > after
> > > > > > > > > > > that,
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > board "goes missing", and I get the dialog asking me if
> > > > I want
> > > > > > > > to
> > > > > > > > > run
> > > > > > > > > > > the
> > > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants to run is
> > > > > > > > VS2008,
> > > > > > > > > even
> > > > > > > > > > > > > though
> > > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the "debug"
> > > > prompt,
> > > > > > > > it
> > > > > > > > > opens
> > > > > > > > > > > > > > VS2008, loads the current source file, and that's it. No
> > > > > > > > debugger,
> > > > > > > > > no
> > > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration thing,
> > > > due to
> > > > > > > > > having
> > > > > > > > > > > both
> > > > > > > > > > > > > > versions installed, but I not only don't know how to fix
> > > > it, I
> > > > > > > > am
> > > > > > > > > > > > > reluctant
> > > > > > > > > > > > > > to try to get 2008 working in that context, for fear it
> > > > will
> > > > > > > > screw
> > > > > > > > > up
> > > > > > > > > > > > > 2010,
> > > > > > > > > > > > > > which is what I generally use. I only installed 2008 to
> > > > be
> > > > > > > > able to
> > > > > > > > > > > build
> > > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing
> > > > Persist[100], while
> > > > > > > > > not
> > > > > > > > > > > the
> > > > > > > > > > > > > > actual cause of the problem, is somehow triggering
> > > > whatever it
> > > > > > > > is
> > > > > > > > > that
> > > > > > > > > > > is
> > > > > > > > > > > > > > going wrong, but I'm totally at a loss to understand
> > > > what is
> > > > > > > > going
> > > > > > > > > > > wrong,
> > > > > > > > > > > > > or
> > > > > > > > > > > > > > how, and have had no success in trying to narrow it
> > > > down. If I
> > > > > > > > > comment
> > > > > > > > > > > out
> > > > > > > > > > > > > > the one line that clears Persist[100] after a PCComm
> > > > command,
> > > > > > > > the
> > > > > > > > > > > problem
> > > > > > > > > > > > > > goes away entirely, and everything works perfectly. If I
> > > > change
> > > > > > > > > that
> > > > > > > > > > > one
> > > > > > > > > > > > > > line to write *any* other location, like 99, or 101, the
> > > > > > > > failure
> > > > > > > > > > > > > "signature"
> > > > > > > > > > > > > > changes - rather than crashing almost immediately after
> > > > the
> > > > > > > > > Persist
> > > > > > > > > > > > > location
> > > > > > > > > > > > > > is written, the app continues to run normally until I
> > > > close
> > > > > > > > it.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > But, if I then re-start the app without first
> > > > > > > > disconnecting
> > > > > > > > > and
> > > > > > > > > > > > > > reconnecting the board, I get the debug dialog again as
> > > > soon as
> > > > > > > > > the
> > > > > > > > > > > new
> > > > > > > > > > > > > app
> > > > > > > > > > > > > > instance recognizes the connection is available, and
> > > > does its
> > > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > > initialization. I've stepped through all the init code
> > > > and the
> > > > > > > > > > > > > constructors
> > > > > > > > > > > > > > on that second start-up, and whatever is going wrong is
> > > > going
> > > > > > > > > wrong
> > > > > > > > > > > AFTER
> > > > > > > > > > > > > > they have all run, and I don't know how to stop it at a
> > > > point
> > > > > > > > that
> > > > > > > > > > > would
> > > > > > > > > > > > > > give me any useful information about what is going
> > > > wrong.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used
> > > > for
> > > > > > > > PComm (I
> > > > > > > > > > > shifted
> > > > > > > > > > > > > > it from Var 100 to 80), the problem follows it to the
> > > > new
> > > > > > > > > location. So
> > > > > > > > > > > > > it's
> > > > > > > > > > > > > > not the specific location that's at issue, it has to be
> > > > > > > > something
> > > > > > > > > > > > > connected
> > > > > > > > > > > > > > with that functionality. But we know the DSP side works
> > > > fine,
> > > > > > > > and
> > > > > > > > > the
> > > > > > > > > > > PC
> > > > > > > > > > > > > > side isn't actually *doing* anything, other than writing
> > > > that
> > > > > > > > one
> > > > > > > > > > > word. So
> > > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller
> > > > accesses are
> > > > > > > > > > > surrounded
> > > > > > > > > > > > > > with locks, and I'm not doing anything that requires
> > > > grabbing
> > > > > > > > the
> > > > > > > > > > > token
> > > > > > > > > > > > > (the
> > > > > > > > > > > > > > functions for doing Gather operations do use the token,
> > > > but
> > > > > > > > those
> > > > > > > > > are
> > > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > At the point where it's crashing, there are three
> > > > threads
> > > > > > > > > > > running:
> > > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > > 2) A thread running the WCF server for the
> > > > toolpath
> > > > > > > > display
> > > > > > > > > > > (which
> > > > > > > > > > > > > is
> > > > > > > > > > > > > > basically idle, since the toolpath window is not open)
> > > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI
> > > > > > > > updates
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a
> > > > 100mSec
> > > > > > > > > rate,
> > > > > > > > > > > mostly
> > > > > > > > > > > > > > for periodically testing the connection, and updating
> > > > the
> > > > > > > > > "connected"
> > > > > > > > > > > LED
> > > > > > > > > > > > > in
> > > > > > > > > > > > > > the GUI, and showing me the GUI state through a set of
> > > > > > > > on-screen
> > > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > > This thread is the one that calls the PCComm handler.
> > > > All Timer
> > > > > > > > > > > methods
> > > > > > > > > > > > > are
> > > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my
> > > > code if
> > > > > > > > > that
> > > > > > > > > > > would
> > > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3655 |
From: Brad Murry |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Hello Ray, 20ms is a bit of time, but I think those methods are firing off several USB calls under the hood, and remember Windows can only *guarantee a ~15ms process slice tolerance. The only way to gain much more performance is to manually calculate your positions from the MainStatus object. -Brad Murry From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On Behalf Of himykabibble Sent: Wednesday, February 01, 2012 9:56 AM To: DynoMotion@yahoogroups.com Subject: [DynoMotion] Re: Need Some Ideas.... I was calling KM_Controller.Interpreter.ReadCurInterpreterPosition() for EACH axis - not very efficient. So I now call it once per update, and I'm now seeing 8-10 updates/second - not too bad, and it is visually MUCH better. Still seems to me 20mSec is a very long time for that call, no?
Regards, Ray L.
--- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@...> wrote: > > Here is where my problem lies: > > KM_Controller.Interpreter.ReadCurInterpreterPosition() and KM_Controller.Interpreter.ReadCurMachinePosition() are taking an average of 20 mSec each. For four axes, that's about 80mSec per update. I also found a bug in my code that was causing it to do frequent MainStatus reads, but I've commented that code out for now. My display update code takes, in average, less than a mSec to run. It is the dotNet calls that are slowing me down. If I comment out the one line containing the above call, my update rate jumps from ~4/second up to ~12/second. ALL other code is still running. Most other dotNet calls, seem to average on the order of 2-3mSec. Are the above calls not the same ones Brads apps use to get position? Why is it so slow for me? > > Regards, > Ray L. > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote: > > > > BTW - I am no longer seeing ANY hangs, even when I hammer it with printfs and PCComms. > > > > Regards, > > Ray L. > > > > --- In DynoMotion@yahoogroups.com, "himykabibble" <jagboy@> wrote: > > > > > > Brad, > > > > > > I'm not convinced the slowness I'm seeing is associated with any particular feature. It seems pretty random. I did find a bug in my StringGather that caused it to be transferring more data than it should have, but the overall update timing is slow, and quite variable, so I think it's either too much traffic, and/or a lot of blocking going on. I'm going to measure what the update loop time is. It's certainly not close to the 10/second it should be. > > > > > > Is there any problem with asynchronous reads of GUI controls and other objects associated with the GUI thread? > > > > > > I'd be curious what kind of update rate you see if you run the following on the DSP with a dotNet app. I see the messages coming about every 1/4 second or so, while under KMotion it looks like about 10/second, as it should be. > > > > > > while(1) > > > { > > > int i; > > > printf )"1\n"); > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); } > > > printf )"2\n"); > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); } > > > printf )"3\n"); > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); } > > > } > > > > > > Regards, > > > Ray L. > > > > > > --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote: > > > > > > > > ServiceConsole was not fully implemented, I wonder if that message pump is > > > > getting clogged. > > > > > > > > > > > > > > > > It is now implemented, as I saw it was being used in KMotionCNC. > > > > > > > > > > > > > > > > Not sure if that is a/the issue though. > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On > > > > Behalf Of himykabibble > > > > Sent: Tuesday, January 31, 2012 10:00 PM > > > > To: DynoMotion@yahoogroups.com > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > Tom/Brad, > > > > > > > > Earlier I was again seeing hangs associated with PCComm and/or Console > > > > messages. I added a message queue for the console messages, and it seems to > > > > be working solidly again, albeit slow. The GUI will sometimes become > > > > unresponsive for several seconds (up to 15 at times), then come back to > > > > life. Even when it's working, it seems sluggish to me. As I mentioned, the > > > > DROs seem to be updating only about 2-3 times per second. If I run a DSP > > > > program that does a printf every 2000 time slices, the messages come out at > > > > irregular intervals. If I send the messages through PCComm, both the average > > > > time, and the irregularity are much greater, with the bulk of time being > > > > spent doing the String gathers, which sometimes take as much as 2 or 3 > > > > seconds to complete, for a message that is only about a dozen characters. I > > > > have to assume I still have some blocking problems. Any suggestions how to > > > > find them? > > > > > > > > Regards, > > > > Ray L. > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > What I'm seeing right now is VERY long times to do the gather in PCComm to > > > > retrieve a short String - sometimes on the order of several seconds to > > > > retrieve a String that is perhaps a dozen characters. printfs are coming > > > > through reliably, and quickly. It seems to me like most operations that are > > > > talking to the board are taking an inordinately long time to complete, > > > > slowing everything down. I have no doubts this is a threading issue, but I > > > > don't know what, and VS2010 seems to provide no support for examining > > > > threads... > > > > > > > > > > Regards, > > > > > Ray L. > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > Unfortunately, my celebration turns out to be a bit premature. My > > > > deadlocks are back, after making a few minor changes.... I also noticed > > > > today while running on the machine that DRO updates are still very slow - on > > > > the order to 2-3 updates/seconds. I suspect there's a lot of waiting going > > > > on somewhere in there. > > > > > > > > > > > > Regards, > > > > > > Ray L. > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > , Andrew Ford <ahford@> wrote: > > > > > > > > > > > > > > I'm able to get the same hang in Kmotion with a printf every second or > > > > so. > > > > > > > I didn't take too close a look at it in the debugger but it looks like > > > > a > > > > > > > deadlock. I could take a closer look again tonight. > > > > > > > > > > > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote: > > > > > > > > > > > > > > > ** > > > > > > > > > > > > > > > > > > > > > > > > Hi Ray, > > > > > > > > > > > > > > > > BTW the DSP printfs send unsolicited messages to the PC. Whenever an > > > > App > > > > > > > > does a ReadLine from KFLOP the KMotionServer will do a read from > > > > KFLOP and > > > > > > > > may get back the unsolicited message instead of the expected > > > > response. In > > > > > > > > that case the unsolicited message received will be sent to the App > > > > via the > > > > > > > > ConsoleCallback and then another read will be performed to get the > > > > expected > > > > > > > > response. > > > > > > > > > > > > > > > > So from your description it seems like the crash is somehow being > > > > caused > > > > > > > > by the ConsoleCallback possibly due to a bug in the .Net interface > > > > or > > > > > > > > because the Console is doing something bad in your GUI. Maybe change > > > > the > > > > > > > > ConsoleCallback to just discard the message to help narrow things > > > > down. > > > > > > > > > > > > > > > > It isn't clear to me if the crash you report having in the > > > > MarshalPost is > > > > > > > > before the call or after. > > > > > > > > > > > > > > > > Regards > > > > > > > > TK > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *From:* himykabibble <jagboy@> > > > > > > > > *To:* DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > *Sent:* Monday, January 30, 2012 4:14 PM > > > > > > > > > > > > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > As of last night, thanks to Toms suggestion to look at the DSP code, > > > > > > > > PCComm works, as does MDI from the DSP (and I assume most of the > > > > other > > > > > > > > functions, though I haven't tested them all yet). (Mind you, that > > > > same DSP > > > > > > > > code, printfs and all, works perfectly under KMotionCNC...) PCComm > > > > was > > > > > > > > "fixed" by getting rid of the printfs in the DSP code. Put the > > > > printfs > > > > > > > > back, and it starts locking up again (in CheckIsReady() before, but > > > > now in > > > > > > > > MarshalPost within WriteLineReadLine - At least it's a > > > > dead-consistent > > > > > > > > failure!). Console messages also work fine, as long as there are NO > > > > printfs > > > > > > > > in the DSP code. > > > > > > > > > > > > > > > > Regards, > > > > > > > > Ray L. > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I thought the main issue we were working on was the printf's/PComm > > > > > > > > issues in > > > > > > > > > your user programs, has that situation improved at all? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Good that your MDI code works though. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> ] On > > > > > > > > > Behalf Of himykabibble > > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM > > > > > > > > > To: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the MDI > > > > problem, > > > > > > > > but I > > > > > > > > > still get the hangs in CheckIsRead() when I have the console > > > > callback > > > > > > > > > updating the TextBox, even though it is now also being invoked. > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > , > > > > > > > > > "bradodarb" <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I just > > > > needed to > > > > > > > > > invoke them. Kinda weird, you usually only need to invoke calls to > > > > your > > > > > > > > GUI > > > > > > > > > components, but in my case an HTML button is being clicked, > > > > handled by > > > > > > > > > jscript COM marshaling over to a method in my c# code. Maybe the > > > > printf > > > > > > > > is > > > > > > > > > using some [STAThread ] component.. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > So Ray, surround your calls in an invoke clause as well and see > > > > if it > > > > > > > > > improves. > > > > > > > > > > > > > > > > > > > > Here is a nice tidy way to do it:: > > > > > > > > > > > > > > > > > > > > public void UpdateDocument(Action action) > > > > > > > > > > { > > > > > > > > > > if (_GuiHost.Parent.InvokeRequired) > > > > > > > > > > { > > > > > > > > > > _GuiHost.Parent.Invoke(action); > > > > > > > > > > } > > > > > > > > > > else > > > > > > > > > > { > > > > > > > > > > action(); > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > And then in your code that runs the CompileAndLoad, etc.. :: > > > > > > > > > > > > > > > > > > > > UpdateDocument(new Action(delegate() > > > > > > > > > > { > > > > > > > > > > //Your existing code inside here > > > > > > > > > > } > > > > > > > > > > )); > > > > > > > > > > > > > > > > > > > > Let me know if this helps. > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > , > > > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > You should invoke it to your textbox. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > In related news, I have no issues running any of my previously > > > > > > > > > problematic > > > > > > > > > > > procedures inside a console app.. Only crashes my winforms > > > > > > > > browserapp. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > ] > > > > > > > > > On > > > > > > > > > > > Behalf Of himykabibble > > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM > > > > > > > > > > > To: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > > > > > I wired in the console message handler, and I now get frequent > > > > > > > > lock-ups. > > > > > > > > > My > > > > > > > > > > > handler does nothing more than one line of code that stuffs > > > > the > > > > > > > > String > > > > > > > > > > > argument into a TextBox. With that one line commented out, all > > > > is > > > > > > > > good. > > > > > > > > > But > > > > > > > > > > > if I uncomment that one line, then I get frequent hangs - the > > > > app > > > > > > > > just > > > > > > > > > locks > > > > > > > > > > > up. No errors, exceptions, or anything but the GUI stops > > > > responding > > > > > > > > > > > entirely. The callback does work as it should, until the app > > > > locks > > > > > > > > up. > > > > > > > > > Is > > > > > > > > > > > this a threading thing? Nobody else writes to that TextBox. > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > > > > > > > Well it makes me happy to see someone besides me having > > > > strange > > > > > > > > things > > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of your > > > > problem > > > > > > > > it > > > > > > > > > will > > > > > > > > > > > fix mine as well. > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > , > > > > > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works > > > > just > > > > > > > > fine, > > > > > > > > > it > > > > > > > > > > > only > > > > > > > > > > > > > crashes when I use the InvokeAction. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user > > > > buttons. If > > > > > > > > you > > > > > > > > > look > > > > > > > > > > > at > > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires the > > > > button > > > > > > > > > commands as > > > > > > > > > > > if > > > > > > > > > > > > > they were any other MCode. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Still, it does not explain why it works for me and not you > > > > using > > > > > > > > the > > > > > > > > > > > > > CompileAndLoadCoff. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Then again, I am not using any PComm in my test > > > > prog(print.c). > > > > > > > > I'll > > > > > > > > > try > > > > > > > > > > > > > that and get back to you. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > > > > > > On > > > > > > > > > > > > > Behalf Of himykabibble > > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > > > > > > > > > No, I do not have the message event hooked up in my app. > > > > > > > > (Actually, > > > > > > > > > > > didn't > > > > > > > > > > > > > even know how to, but now I do! Cool!). > > > > > > > > > > > > > > > > > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is > > > > > > > > > InvokeAction a > > > > > > > > > > > > > better way to do it? > > > > > > > > > > > > > > > > > > > > > > > > > > I've just run into a new problem as well. Two steps > > > > forward, one > > > > > > > > > > > > > backward.... MDI commands, which WERE working fine, now > > > > are not. > > > > > > > > > > > Non-motion > > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion > > > > > > > > commands > > > > > > > > > never > > > > > > > > > > > > > issue a Completed callback. The move IS completed, I get > > > > the > > > > > > > > status > > > > > > > > > > > > > callback, then nothing. When I halt the interpreter, by > > > > hitting > > > > > > > > my > > > > > > > > > > > E-stop > > > > > > > > > > > > > button, or re-starting the App, THEN I get the completed > > > > > > > > callback. > > > > > > > > > So > > > > > > > > > > > > > something is blocking something there as well. This was > > > > working > > > > > > > > fine > > > > > > > > > > > until I > > > > > > > > > > > > > fixed the original PCComm problem. > > > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am wondering if there are some .net memory sharing > > > > issues > > > > > > > > going > > > > > > > > > on > > > > > > > > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I just set one of my user buttons to fire off the > > > > print.c > > > > > > > > program > > > > > > > > > and > > > > > > > > > > > I > > > > > > > > > > > > > get > > > > > > > > > > > > > > the same result. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Do you have the message event wired up? - > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _Controller.MessageUpdated += new > > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an > > > > > > > > immediate > > > > > > > > > > > crash. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > It is interesting to note that we get the print messages > > > > just > > > > > > > > fine > > > > > > > > > > > from > > > > > > > > > > > > > the > > > > > > > > > > > > > > c# console application. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > So I tried this code in my button event handler as a > > > > quick and > > > > > > > > > dirty > > > > > > > > > > > > > test:: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + > > > > @"\C > > > > > > > > > > > > > > Programs\KMotionCNC\print.c"; > > > > > > > > > > > > > > > > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1, > > > > > > > > > > > > > > TheCFile, false)); > > > > > > > > > > > > > > > > > > > > > > > > > > > > //Excecute the program we just loaded > > > > > > > > > > > > > > > > > > > > > > > > > > > > _Controller.WriteLine("Execute1"); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no > > > > crashes). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing > > > > something > > > > > > > > screwy > > > > > > > > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via > > > > > > > > Interpreter.InvokeAction > > > > > > > > > as > > > > > > > > > > > well? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > > > > > > > > On > > > > > > > > > > > > > > Behalf Of himykabibble > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > > > > > > > > > > > > > > > I know this is a stupid question, but is there some > > > > > > > > interaction or > > > > > > > > > > > shared > > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer and > > > > printfs? I > > > > > > > > > had > > > > > > > > > > > some > > > > > > > > > > > > > > printfs in the Home code that I had put in while beating > > > > on > > > > > > > > this > > > > > > > > > > > thing. I > > > > > > > > > > > > > > just took them out, and it's now working. Nothing else > > > > has > > > > > > > > > changed. > > > > > > > > > > > > > printfs > > > > > > > > > > > > > > still do not come out in the KMotion console after I > > > > re-start > > > > > > > > my > > > > > > > > > app, > > > > > > > > > > > so > > > > > > > > > > > > > > there is something still not completely right, but > > > > PCComm is > > > > > > > > now > > > > > > > > > > > working, > > > > > > > > > > > > > so > > > > > > > > > > > > > > thanks for pointing me in the right direction. I just > > > > didn't > > > > > > > > even > > > > > > > > > > > really > > > > > > > > > > > > > > consider the DSP Code, because it's always worked under > > > > > > > > > KMotionCNC.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > What could cause KMotion to be able to talk to the board > > > > just > > > > > > > > > fine, > > > > > > > > > > > but > > > > > > > > > > > > > NOT > > > > > > > > > > > > > > see printfs? For that matter, when in that state, it > > > > does not > > > > > > > > see > > > > > > > > > DSP > > > > > > > > > > > > > tasks > > > > > > > > > > > > > > running either, as indficated as there are no green > > > > highlights > > > > > > > > on > > > > > > > > > the > > > > > > > > > > > task > > > > > > > > > > > > > > IDs next to the editor window. But after re-starting > > > > Kmotion, > > > > > > > > > without > > > > > > > > > > > > > > restarting my app, all is well. > > > > > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > The DSP code is my home function, which works > > > > perfectly under > > > > > > > > > > > > > KMotionCNC. > > > > > > > > > > > > > > But, just to be sure, I went to a three line program: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > main() > > > > > > > > > > > > > > > { > > > > > > > > > > > > > > > printf("Doing MsgBox\n"); > > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK); > > > > > > > > > > > > > > > printf("MsgBox Done\n"); > > > > > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > This gives a different result. The first printf > > > > appears every > > > > > > > > > time. > > > > > > > > > > > The > > > > > > > > > > > > > > second one never appears. My app does not crash or > > > > behave > > > > > > > > > strangely in > > > > > > > > > > > any > > > > > > > > > > > > > > way that I can see, even if I open and close it several > > > > times. > > > > > > > > > But, if > > > > > > > > > > > I > > > > > > > > > > > > > > open KMotion, then open my app, then close it, then > > > > re-open it, > > > > > > > > > > > KMotion > > > > > > > > > > > > > will > > > > > > > > > > > > > > still be able to talk to the board, and execute commands > > > > from > > > > > > > > the > > > > > > > > > > > console, > > > > > > > > > > > > > > but printfs from the DSP no longer show up in the > > > > console > > > > > > > > window, > > > > > > > > > > > until I > > > > > > > > > > > > > > close then re-open KMotion. Does that make any sense? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I will try to narrow down what in the Home program is > > > > > > > > > influencing > > > > > > > > > > > the > > > > > > > > > > > > > > PCComm stuff. But what could that program be doing that > > > > it > > > > > > > > > wouldn't be > > > > > > > > > > > > > doing > > > > > > > > > > > > > > when run under KMotionCNC, where it's always works > > > > perfectly?? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I'll post the code tomorrow. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > > > > > > TK <tk@> wrote: > > > > > > > > > > > >
(Message over 64 KB, truncated)
|
|
Group: DynoMotion |
Message: 3656 |
From: himykabibble |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Brad,
I removed all use of MainStatus due to problems, which perhaps were ghosts. Should I put it back in?
I'm running about 8 updates/second right now, albeit with a fair amount of "jitter", which is at least tolerable, but it sure looks better at 10-12.
Are the "one off" problems in MainStatus fixed?
Another problem I'm seeing: KMAxes[].CheckEnabled() always returns false. I am assuming if I init and axis with:
KMAxes.Add("XAxis", new KMotion_dotNet.KM_Axis(KMController, 0, "XAxis"));
that this should work:
KMAxes["XAxis"].CheckEnabled()
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@...> wrote:
>
> Hello Ray,
>
>
>
> 20ms is a bit of time, but I think those methods are firing off several USB
> calls under the hood, and remember Windows can only *guarantee a ~15ms
> process slice tolerance.
>
>
>
> The only way to gain much more performance is to manually calculate your
> positions from the MainStatus object.
>
>
>
> -Brad Murry
>
>
>
> From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> Behalf Of himykabibble
> Sent: Wednesday, February 01, 2012 9:56 AM
> To: DynoMotion@yahoogroups.com
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
>
>
>
> I was calling KM_Controller.Interpreter.ReadCurInterpreterPosition() for
> EACH axis - not very efficient. So I now call it once per update, and I'm
> now seeing 8-10 updates/second - not too bad, and it is visually MUCH
> better. Still seems to me 20mSec is a very long time for that call, no?
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> "himykabibble" <jagboy@> wrote:
> >
> > Here is where my problem lies:
> >
> > KM_Controller.Interpreter.ReadCurInterpreterPosition() and
> KM_Controller.Interpreter.ReadCurMachinePosition() are taking an average of
> 20 mSec each. For four axes, that's about 80mSec per update. I also found a
> bug in my code that was causing it to do frequent MainStatus reads, but I've
> commented that code out for now. My display update code takes, in average,
> less than a mSec to run. It is the dotNet calls that are slowing me down. If
> I comment out the one line containing the above call, my update rate jumps
> from ~4/second up to ~12/second. ALL other code is still running. Most other
> dotNet calls, seem to average on the order of 2-3mSec. Are the above calls
> not the same ones Brads apps use to get position? Why is it so slow for me?
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> "himykabibble" <jagboy@> wrote:
> > >
> > > BTW - I am no longer seeing ANY hangs, even when I hammer it with
> printfs and PCComms.
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> , "himykabibble" <jagboy@> wrote:
> > > >
> > > > Brad,
> > > >
> > > > I'm not convinced the slowness I'm seeing is associated with any
> particular feature. It seems pretty random. I did find a bug in my
> StringGather that caused it to be transferring more data than it should
> have, but the overall update timing is slow, and quite variable, so I think
> it's either too much traffic, and/or a lot of blocking going on. I'm going
> to measure what the update loop time is. It's certainly not close to the
> 10/second it should be.
> > > >
> > > > Is there any problem with asynchronous reads of GUI controls and other
> objects associated with the GUI thread?
> > > >
> > > > I'd be curious what kind of update rate you see if you run the
> following on the DSP with a dotNet app. I see the messages coming about
> every 1/4 second or so, while under KMotion it looks like about 10/second,
> as it should be.
> > > >
> > > > while(1)
> > > > {
> > > > int i;
> > > > printf )"1\n");
> > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > > printf )"2\n");
> > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > > printf )"3\n");
> > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > > }
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote:
> > > > >
> > > > > ServiceConsole was not fully implemented, I wonder if that message
> pump is
> > > > > getting clogged.
> > > > >
> > > > >
> > > > >
> > > > > It is now implemented, as I saw it was being used in KMotionCNC.
> > > > >
> > > > >
> > > > >
> > > > > Not sure if that is a/the issue though.
> > > > >
> > > > >
> > > > >
> > > > > -Brad Murry
> > > > >
> > > > >
> > > > >
> > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > Behalf Of himykabibble
> > > > > Sent: Tuesday, January 31, 2012 10:00 PM
> > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
>
> > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Tom/Brad,
> > > > >
> > > > > Earlier I was again seeing hangs associated with PCComm and/or
> Console
> > > > > messages. I added a message queue for the console messages, and it
> seems to
> > > > > be working solidly again, albeit slow. The GUI will sometimes become
> > > > > unresponsive for several seconds (up to 15 at times), then come back
> to
> > > > > life. Even when it's working, it seems sluggish to me. As I
> mentioned, the
> > > > > DROs seem to be updating only about 2-3 times per second. If I run a
> DSP
> > > > > program that does a printf every 2000 time slices, the messages come
> out at
> > > > > irregular intervals. If I send the messages through PCComm, both the
> average
> > > > > time, and the irregularity are much greater, with the bulk of time
> being
> > > > > spent doing the String gathers, which sometimes take as much as 2 or
> 3
> > > > > seconds to complete, for a message that is only about a dozen
> characters. I
> > > > > have to assume I still have some blocking problems. Any suggestions
> how to
> > > > > find them?
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> ,
> > > > > "himykabibble" <jagboy@> wrote:
> > > > > >
> > > > > > What I'm seeing right now is VERY long times to do the gather in
> PCComm to
> > > > > retrieve a short String - sometimes on the order of several seconds
> to
> > > > > retrieve a String that is perhaps a dozen characters. printfs are
> coming
> > > > > through reliably, and quickly. It seems to me like most operations
> that are
> > > > > talking to the board are taking an inordinately long time to
> complete,
> > > > > slowing everything down. I have no doubts this is a threading issue,
> but I
> > > > > don't know what, and VS2010 seems to provide no support for
> examining
> > > > > threads...
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> ,
> > > > > "himykabibble" <jagboy@> wrote:
> > > > > > >
> > > > > > > Unfortunately, my celebration turns out to be a bit premature.
> My
> > > > > deadlocks are back, after making a few minor changes.... I also
> noticed
> > > > > today while running on the machine that DRO updates are still very
> slow - on
> > > > > the order to 2-3 updates/seconds. I suspect there's a lot of waiting
> going
> > > > > on somewhere in there.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > , Andrew Ford <ahford@> wrote:
> > > > > > > >
> > > > > > > > I'm able to get the same hang in Kmotion with a printf every
> second or
> > > > > so.
> > > > > > > > I didn't take too close a look at it in the debugger but it
> looks like
> > > > > a
> > > > > > > > deadlock. I could take a closer look again tonight.
> > > > > > > >
> > > > > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> > > > > > > >
> > > > > > > > > **
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Hi Ray,
> > > > > > > > >
> > > > > > > > > BTW the DSP printfs send unsolicited messages to the PC.
> Whenever an
> > > > > App
> > > > > > > > > does a ReadLine from KFLOP the KMotionServer will do a read
> from
> > > > > KFLOP and
> > > > > > > > > may get back the unsolicited message instead of the expected
> > > > > response. In
> > > > > > > > > that case the unsolicited message received will be sent to
> the App
> > > > > via the
> > > > > > > > > ConsoleCallback and then another read will be performed to
> get the
> > > > > expected
> > > > > > > > > response.
> > > > > > > > >
> > > > > > > > > So from your description it seems like the crash is somehow
> being
> > > > > caused
> > > > > > > > > by the ConsoleCallback possibly due to a bug in the .Net
> interface
> > > > > or
> > > > > > > > > because the Console is doing something bad in your GUI.
> Maybe change
> > > > > the
> > > > > > > > > ConsoleCallback to just discard the message to help narrow
> things
> > > > > down.
> > > > > > > > >
> > > > > > > > > It isn't clear to me if the crash you report having in the
> > > > > MarshalPost is
> > > > > > > > > before the call or after.
> > > > > > > > >
> > > > > > > > > Regards
> > > > > > > > > TK
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > *From:* himykabibble <jagboy@>
> > > > > > > > > *To:* DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > *Sent:* Monday, January 30, 2012 4:14 PM
> > > > > > > > >
> > > > > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Brad,
> > > > > > > > >
> > > > > > > > > As of last night, thanks to Toms suggestion to look at the
> DSP code,
> > > > > > > > > PCComm works, as does MDI from the DSP (and I assume most of
> the
> > > > > other
> > > > > > > > > functions, though I haven't tested them all yet). (Mind you,
> that
> > > > > same DSP
> > > > > > > > > code, printfs and all, works perfectly under KMotionCNC...)
> PCComm
> > > > > was
> > > > > > > > > "fixed" by getting rid of the printfs in the DSP code. Put
> the
> > > > > printfs
> > > > > > > > > back, and it starts locking up again (in CheckIsReady()
> before, but
> > > > > now in
> > > > > > > > > MarshalPost within WriteLineReadLine - At least it's a
> > > > > dead-consistent
> > > > > > > > > failure!). Console messages also work fine, as long as there
> are NO
> > > > > printfs
> > > > > > > > > in the DSP code.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Ray L.
> > > > > > > > >
> > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@>
> wrote:
> > > > > > > > > >
> > > > > > > > > > Ray,
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I thought the main issue we were working on was the
> printf's/PComm
> > > > > > > > > issues in
> > > > > > > > > > your user programs, has that situation improved at all?
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Good that your MDI code works though.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > -Brad
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the
> MDI
> > > > > problem,
> > > > > > > > > but I
> > > > > > > > > > still get the hangs in CheckIsRead() when I have the
> console
> > > > > callback
> > > > > > > > > > updating the TextBox, even though it is now also being
> invoked.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > ,
> > > > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I
> just
> > > > > needed to
> > > > > > > > > > invoke them. Kinda weird, you usually only need to invoke
> calls to
> > > > > your
> > > > > > > > > GUI
> > > > > > > > > > components, but in my case an HTML button is being
> clicked,
> > > > > handled by
> > > > > > > > > > jscript COM marshaling over to a method in my c# code.
> Maybe the
> > > > > printf
> > > > > > > > > is
> > > > > > > > > > using some [STAThread ] component..
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > So Ray, surround your calls in an invoke clause as well
> and see
> > > > > if it
> > > > > > > > > > improves.
> > > > > > > > > > >
> > > > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > > > >
> > > > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > > > {
> > > > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > > > {
> > > > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > > > }
> > > > > > > > > > > else
> > > > > > > > > > > {
> > > > > > > > > > > action();
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > > And then in your code that runs the CompileAndLoad,
> etc.. ::
> > > > > > > > > > >
> > > > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > > > {
> > > > > > > > > > > //Your existing code inside here
> > > > > > > > > > > }
> > > > > > > > > > > ));
> > > > > > > > > > >
> > > > > > > > > > > Let me know if this helps.
> > > > > > > > > > >
> > > > > > > > > > > -Brad Murry
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > ,
> > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > In related news, I have no issues running any of my
> previously
> > > > > > > > > > problematic
> > > > > > > > > > > > procedures inside a console app.. Only crashes my
> winforms
> > > > > > > > > browserapp.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > ]
> > > > > > > > > > On
> > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > >
> > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Brad,
> > > > > > > > > > > >
> > > > > > > > > > > > I wired in the console message handler, and I now get
> frequent
> > > > > > > > > lock-ups.
> > > > > > > > > > My
> > > > > > > > > > > > handler does nothing more than one line of code that
> stuffs
> > > > > the
> > > > > > > > > String
> > > > > > > > > > > > argument into a TextBox. With that one line commented
> out, all
> > > > > is
> > > > > > > > > good.
> > > > > > > > > > But
> > > > > > > > > > > > if I uncomment that one line, then I get frequent
> hangs - the
> > > > > app
> > > > > > > > > just
> > > > > > > > > > locks
> > > > > > > > > > > > up. No errors, exceptions, or anything but the GUI
> stops
> > > > > responding
> > > > > > > > > > > > entirely. The callback does work as it should, until
> the app
> > > > > locks
> > > > > > > > > up.
> > > > > > > > > > Is
> > > > > > > > > > > > this a threading thing? Nobody else writes to that
> TextBox.
> > > > > > > > > > > >
> > > > > > > > > > > > Regards,
> > > > > > > > > > > > Ray L.
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > Well it makes me happy to see someone besides me
> having
> > > > > strange
> > > > > > > > > things
> > > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of
> your
> > > > > problem
> > > > > > > > > it
> > > > > > > > > > will
> > > > > > > > > > > > fix mine as well.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> <mailto:%0b>
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > ,
> > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff
> everything works
> > > > > just
> > > > > > > > > fine,
> > > > > > > > > > it
> > > > > > > > > > > > only
> > > > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user
> > > > > buttons. If
> > > > > > > > > you
> > > > > > > > > > look
> > > > > > > > > > > > at
> > > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires
> the
> > > > > button
> > > > > > > > > > commands as
> > > > > > > > > > > > if
> > > > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Still, it does not explain why it works for me and
> not you
> > > > > using
> > > > > > > > > the
> > > > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Then again, I am not using any PComm in my test
> > > > > prog(print.c).
> > > > > > > > > I'll
> > > > > > > > > > try
> > > > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > -Brad
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> <mailto:%0b>
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > On
> > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > No, I do not have the message event hooked up in
> my app.
> > > > > > > > > (Actually,
> > > > > > > > > > > > didn't
> > > > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I am running the C programs using
> CompileAndLoadCoff. Is
> > > > > > > > > > InvokeAction a
> > > > > > > > > > > > > > better way to do it?
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I've just run into a new problem as well. Two
> steps
> > > > > forward, one
> > > > > > > > > > > > > > backward.... MDI commands, which WERE working
> fine, now
> > > > > are not.
> > > > > > > > > > > > Non-motion
> > > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but
> motion
> > > > > > > > > commands
> > > > > > > > > > never
> > > > > > > > > > > > > > issue a Completed callback. The move IS completed,
> I get
> > > > > the
> > > > > > > > > status
> > > > > > > > > > > > > > callback, then nothing. When I halt the
> interpreter, by
> > > > > hitting
> > > > > > > > > my
> > > > > > > > > > > > E-stop
> > > > > > > > > > > > > > button, or re-starting the App, THEN I get the
> completed
> > > > > > > > > callback.
> > > > > > > > > > So
> > > > > > > > > > > > > > something is blocking something there as well.
> This was
> > > > > working
> > > > > > > > > fine
> > > > > > > > > > > > until I
> > > > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> <mailto:%0b>
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I am wondering if there are some .net memory
> sharing
> > > > > issues
> > > > > > > > > going
> > > > > > > > > > on
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I just set one of my user buttons to fire off
> the
> > > > > print.c
> > > > > > > > > program
> > > > > > > > > > and
> > > > > > > > > > > > I
> > > > > > > > > > > > > > get
> > > > > > > > > > > > > > > the same result.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I do, and I get the Hello, World message
> followed by an
> > > > > > > > > immediate
> > > > > > > > > > > > crash.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > It is interesting to note that we get the print
> messages
> > > > > just
> > > > > > > > > fine
> > > > > > > > > > > > from
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > So I tried this code in my button event handler
> as a
> > > > > quick and
> > > > > > > > > > dirty
> > > > > > > > > > > > > > test::
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > String TheCFile =
> _Controller.Interpreter.MainPathRoot +
> > > > > @"\C
> > > > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > And I get my callbacks from the printf just
> fine!(no
> > > > > crashes).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I looks like InvokeAction with printf's are
> doing
> > > > > something
> > > > > > > > > screwy
> > > > > > > > > > > > here.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via
> > > > > > > > > Interpreter.InvokeAction
> > > > > > > > > > as
> > > > > > > > > > > > well?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> <mailto:%0b>
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > > On
> > > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> <mailto:%0b>
> > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I know this is a stupid question, but is there
> some
> > > > > > > > > interaction or
> > > > > > > > > > > > shared
> > > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer
> and
> > > > > printfs? I
> > > > > > > > > > had
> > > > > > > > > > > > some
> > > > > > > > > > > > > > > printfs in the Home code that I had put in while
> beating
> > > > > on
> > > > > > > > > this
> > > > > > > > > > > > thing. I
> > > > > > > > > > > > > > > just took them out, and it's now working.
> Nothing else
> > > > > has
> > > > > > > > > > changed.
> > > > > > > > > > > > > > printfs
> > > > > > > > > > > > > > > still do not come out in the KMotion console
> after I
> > > > > re-start
> > > > > > > > > my
> > > > > > > > > > app,
> > > > > > > > > > > > so
> > > > > > > > > > > > > > > there is something still not completely right,
> but
> > > > > PCComm is
> > > > > > > > > now
> > > > > > > > > > > > working,
> > > > > > > > > > > > > > so
> > > > > > > > > > > > > > > thanks for pointing me in the right direction. I
> just
> > > > > didn't
> > > > > > > > > even
> > > > > > > > > > > > really
> > > > > > > > > > > > > > > consider the DSP Code, because it's always
> worked under
> > > > > > > > > > KMotionCNC....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > What could cause KMotion to be able to talk to
> the board
> > > > > just
> > > > > > > > > > fine,
> > > > > > > > > > > > but
> > > > > > > > > > > > > > NOT
> > > > > > > > > > > > > > > see printfs? For that matter, when in that
> state, it
> > > > > does not
> > > > > > > > > see
> > > > > > > > > > DSP
> > > > > > > > > > > > > > tasks
> > > > > > > > > > > > > > > running either, as indficated as there are no
> green
> > > > > highlights
> > > > > > > > > on
> > > > > > > > > > the
> > > > > > > > > > > > task
> > > > > > > > > > > > > > > IDs next to the editor window. But after
> re-starting
> > > > > Kmotion,
> > > > > > > > > > without
> > > > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > The DSP code is my home function, which works
> > > > > perfectly under
> > > > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > > > But, just to be sure, I went to a three line
> program:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > This gives a different result. The first
> printf
> > > > > appears every
> > > > > > > > > > time.
> > > > > > > > > > > > The
> > > > > > > > > > > > > > > second one never appears. My app does not crash
> or
> > > > > behave
> > > > > > > > > > strangely in
> > > > > > > > > > > > any
> > > > > > > > > > > > > > > way that I can see, even if I open and close it
> several
> > > > > times.
> > > > > > > > > > But, if
> > > > > > > > > > > > I
> > > > > > > > > > > > > > > open KMotion, then open my app, then close it,
> then
> > > > > re-open it,
> > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > still be able to talk to the board, and execute
> commands
> > > > > from
> > > > > > > > > the
> > > > > > > > > > > > console,
> > > > > > > > > > > > > > > but printfs from the DSP no longer show up in
> the
> > > > > console
> > > > > > > > > window,
> > > > > > > > > > > > until I
> > > > > > > > > > > > > > > close then re-open KMotion. Does that make any
> sense?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I will try to narrow down what in the Home
> program is
> > > > > > > > > > influencing
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > PCComm stuff. But what could that program be
> doing that
> > > > > it
> > > > > > > > > > wouldn't be
> > > > > > > > > > > > > > doing
> > > > > > > > > > > > > > > when run under KMotionCNC, where it's always
> works
> > > > > perfectly??
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> <mailto:DynoMotion%40yahoogroups.com>
> > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong.
> But it
> > > > > sounds
> > > > > > > > > > more
> > > > > > > > > > > > like a
> > > > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to
> the PC?
> > > > > What
> > > > > > > > > does
> > > > > > > > > > it
> > > > > > > > > > > > do
> > > > > > > > > > > > > > > after it sees the persist var cleared? What if
> you clear
> > > > > it
> > > > > > > > > from
> > > > > > > > > > the
> > > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > > Console instead? Otherwise I can look at if you
> post all
> > > > > the
> > > > > > > > > code.
> > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble"
> > > > > <jagboy@>
> > > > > > > > > wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you
> has some
> > > > > > > > > suggestions
> > > > > > > > > > on
> > > > > > > > > > > > how
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > proceed. As long as I don't touch Persist[100],
> > > > > everything
> > > > > > > > > works
> > > > > > > > > > just
> > > > > > > > > > > > > > fine.
> > > > > > > > > > > > > > > I can start my app, run programs, exit, connect,
> > > > > disconnect,
> > > > > > > > > and
> > > > > > > > > > it
> > > > > > > > > > > > seems
> > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > work quite reliably. But if I do a MSG on the
> DSP side,
> > > > > my
> > > > > > > > > PCComm
> > > > > > > > > > code
> > > > > > > > > > > > > > > correctly processes it, and clears Persist[100],
> and
> > > > > shortly
> > > > > > > > > after
> > > > > > > > > > > > that,
> > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > board "goes missing", and I get the dialog
> asking me if
> > > > > I want
> > > > > > > > > to
> > > > > > > > > > run
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants
> to run is
> > > > > > > > > VS2008,
> > > > > > > > > > even
> > > > > > > > > > > > > > though
> > > > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the
> "debug"
> > > > > prompt,
> > > > > > > > > it
> > > > > > > > > > opens
> > > > > > > > > > > > > > > VS2008, loads the current source file, and
> that's it. No
> > > > > > > > > debugger,
> > > > > > > > > > no
> > > > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration
> thing,
> > > > > due to
> > > > > > > > > > having
> > > > > > > > > > > > both
> > > > > > > > > > > > > > > versions installed, but I not only don't know
> how to fix
> > > > > it, I
> > > > > > > > > am
> > > > > > > > > > > > > > reluctant
> > > > > > > > > > > > > > > to try to get 2008 working in that context, for
> fear it
> > > > > will
> > > > > > > > > screw
> > > > > > > > > > up
> > > > > > > > > > > > > > 2010,
> > > > > > > > > > > > > > > which is what I generally use. I only installed
> 2008 to
> > > > > be
> > > > > > > > > able to
> > > > > > > > > > > > build
> > > > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing
> > > > > Persist[100], while
> > > > > > > > > > not
> > > > > > > > > > > > the
> > > > > > > > > > > > > > > actual cause of the problem, is somehow
> triggering
> > > > > whatever it
> > > > > > > > > is
> > > > > > > > > > that
> > > > > > > > > > > > is
> > > > > > > > > > > > > > > going wrong, but I'm totally at a loss to
> understand
> > > > > what is
> > > > > > > > > going
> > > > > > > > > > > > wrong,
> > > > > > > > > > > > > > or
> > > > > > > > > > > > > > > how, and have had no success in trying to narrow
> it
> > > > > down. If I
> > > > > > > > > > comment
> > > > > > > > > > > > out
> > > > > > > > > > > > > > > the one line that clears Persist[100] after a
> PCComm
> > > > > command,
> > > > > > > > > the
> > > > > > > > > > > > problem
> > > > > > > > > > > > > > > goes away entirely, and everything works
> perfectly. If I
> > > > > change
> > > > > > > > > > that
> > > > > > > > > > > > one
> > > > > > > > > > > > > > > line to write *any* other location, like 99, or
> 101, the
> > > > > > > > > failure
> > > > > > > > > > > > > > "signature"
> > > > > > > > > > > > > > > changes - rather than crashing almost
> immediately after
> > > > > the
> > > > > > > > > > Persist
> > > > > > > > > > > > > > location
> > > > > > > > > > > > > > > is written, the app continues to run normally
> until I
> > > > > close
> > > > > > > > > it.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > But, if I then re-start the app without
> first
> > > > > > > > > disconnecting
> > > > > > > > > > and
> > > > > > > > > > > > > > > reconnecting the board, I get the debug dialog
> again as
> > > > > soon as
> > > > > > > > > > the
> > > > > > > > > > > > new
> > > > > > > > > > > > > > app
> > > > > > > > > > > > > > > instance recognizes the connection is available,
> and
> > > > > does its
> > > > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > > > initialization. I've stepped through all the
> init code
> > > > > and the
> > > > > > > > > > > > > > constructors
> > > > > > > > > > > > > > > on that second start-up, and whatever is going
> wrong is
> > > > > going
> > > > > > > > > > wrong
> > > > > > > > > > > > AFTER
> > > > > > > > > > > > > > > they have all run, and I don't know how to stop
> it at a
> > > > > point
> > > > > > > > > that
> > > > > > > > > > > > would
> > > > > > > > > > > > > > > give me any useful information about what is
> going
> > > > > wrong.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location
> used
> > > > > for
> > > > > > > > > PComm (I
> > > > > > > > > > > > shifted
> > > > > > > > > > > > > > > it from Var 100 to 80), the problem follows it
> to the
> > > > > new
> > > > > > > > > > location. So
> > > > > > > > > > > > > > it's
> > > > > > > > > > > > > > > not the specific location that's at issue, it
> has to be
> > > > > > > > > something
> > > > > > > > > > > > > > connected
> > > > > > > > > > > > > > > with that functionality. But we know the DSP
> side works
> > > > > fine,
> > > > > > > > > and
> > > > > > > > > > the
> > > > > > > > > > > > PC
> > > > > > > > > > > > > > > side isn't actually *doing* anything, other than
> writing
> > > > > that
> > > > > > > > > one
> > > > > > > > > > > > word. So
> > > > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I've double-checked and all my
> KM_Controller
> > > > > accesses are
> > > > > > > > > > > > surrounded
> > > > > > > > > > > > > > > with locks, and I'm not doing anything that
> requires
> > > > > grabbing
> > > > > > > > > the
> > > > > > > > > > > > token
> > > > > > > > > > > > > > (the
> > > > > > > > > > > > > > > functions for doing Gather operations do use the
> token,
> > > > > but
> > > > > > > > > those
> > > > > > > > > > are
> > > > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > At the point where it's crashing, there
> are three
> > > > > threads
> > > > > > > > > > > > running:
> > > > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > > > 2) A thread running the WCF server for the
> > > > > toolpath
> > > > > > > > > display
> > > > > > > > > > > > (which
> > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > basically idle, since the toolpath window is not
> open)
> > > > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of
> the GUI
> > > > > > > > > updates
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > The app thread also has one Timer running,
> at a
> > > > > 100mSec
> > > > > > > > > > rate,
> > > > > > > > > > > > mostly
> > > > > > > > > > > > > > > for periodically testing the connection, and
> updating
> > > > > the
> > > > > > > > > > "connected"
> > > > > > > > > > > > LED
> > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > the GUI, and showing me the GUI state through a
> set of
> > > > > > > > > on-screen
> > > > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > > > This thread is the one that calls the PCComm
> handler.
> > > > > All Timer
> > > > > > > > > > > > methods
> > > > > > > > > > > > > > are
> > > > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to
> post my
> > > > > code if
> > > > > > > > > > that
> > > > > > > > > > > > would
> > > > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3657 |
From: Andrew Ford |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Hey Tom, That's correct, KMotion.exe deadlocks. I'll have to go repro it, but there may also be a disconnection problem when you have a KFlop printing. I'm not sure if the deadlock occurs because of the combination of these two things or not, I'll have to track it down in the debugger again.
On Tue, Jan 31, 2012 at 6:21 PM, Tom Kerekes <tk@...> wrote:
Hi Andrew,
Sorry this message was marked as spam and was delayed coming through.
Could you explain a bit more. Doing a printf every second or so from KFLOP to the KMotion.exe Console Screen also sometimes freezes KMotion.exe?
Regards
TK
Group: DynoMotion |
Message: 3658 |
From: Brad Murry |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Hello Andrew, I have found that calling the program async works around the issue. -Brad Murry From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On Behalf Of Andrew Ford Sent: Monday, January 30, 2012 5:58 PM To: DynoMotion@yahoogroups.com Subject: Re: [DynoMotion] Re: Need Some Ideas.... I'm able to get the same hang in Kmotion with a printf every second or so. I didn't take too close a look at it in the debugger but it looks like a deadlock. I could take a closer look again tonight. On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@...> wrote: BTW the DSP printfs send unsolicited messages to the PC. Whenever an App does a ReadLine from KFLOP the KMotionServer will do a read from KFLOP and may get back the unsolicited message instead of the expected response. In that case the unsolicited message received will be sent to the App via the ConsoleCallback and then another read will be performed to get the expected response. So from your description it seems like the crash is somehow being caused by the ConsoleCallback possibly due to a bug in the .Net interface or because the Console is doing something bad in your GUI. Maybe change the ConsoleCallback to just discard the message to help narrow things down. It isn't clear to me if the crash you report having in the MarshalPost is before the call or after. Brad,
As of last night, thanks to Toms suggestion to look at the DSP code, PCComm works, as does MDI from the DSP (and I assume most of the other functions, though I haven't tested them all yet). (Mind you, that same DSP code, printfs and all, works perfectly under KMotionCNC...) PCComm was "fixed" by getting rid of the printfs in the DSP code. Put the printfs back, and it starts locking up again (in CheckIsReady() before, but now in MarshalPost within WriteLineReadLine - At least it's a dead-consistent failure!). Console messages also work fine, as long as there are NO printfs in the DSP code.
Regards, Ray L.
--- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@...> wrote: > > Ray, > > > > I thought the main issue we were working on was the printf's/PComm issues in > your user programs, has that situation improved at all? > > > > Good that your MDI code works though. > > > > -Brad > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On > Behalf Of himykabibble > Sent: Monday, January 30, 2012 11:24 AM > To: DynoMotion@yahoogroups.com > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > Brad, > > Putting invokes on my CompileAndLoad calls has fixed the MDI problem, but I > still get the hangs in CheckIsRead() when I have the console callback > updating the TextBox, even though it is now also being invoked. > > Regards, > Ray L. > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > "bradodarb" <bradodarb@> wrote: > > > > > > OK, now I can reliably run my InvokeAction() calls. I just needed to > invoke them. Kinda weird, you usually only need to invoke calls to your GUI > components, but in my case an HTML button is being clicked, handled by > jscript COM marshaling over to a method in my c# code. Maybe the printf is > using some [STAThread ] component.. > > > > > > So Ray, surround your calls in an invoke clause as well and see if it > improves. > > > > Here is a nice tidy way to do it:: > > > > public void UpdateDocument(Action action) > > { > > if (_GuiHost.Parent.InvokeRequired) > > { > > _GuiHost.Parent.Invoke(action); > > } > > else > > { > > action(); > > } > > > > And then in your code that runs the CompileAndLoad, etc.. :: > > > > UpdateDocument(new Action(delegate() > > { > > //Your existing code inside here > > } > > )); > > > > Let me know if this helps. > > > > -Brad Murry > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > Brad Murry <bradodarb@> wrote: > > > > > > Hello Ray, > > > > > > > > > > > > You should invoke it to your textbox. > > > > > > > > > > > > In related news, I have no issues running any of my previously > problematic > > > procedures inside a console app.. Only crashes my winforms browserapp. > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > From: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ] > On > > > Behalf Of himykabibble > > > Sent: Monday, January 30, 2012 10:18 AM > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > Brad, > > > > > > I wired in the console message handler, and I now get frequent lock-ups. > My > > > handler does nothing more than one line of code that stuffs the String > > > argument into a TextBox. With that one line commented out, all is good. > But > > > if I uncomment that one line, then I get frequent hangs - the app just > locks > > > up. No errors, exceptions, or anything but the GUI stops responding > > > entirely. The callback does work as it should, until the app locks up. > Is > > > this a threading thing? Nobody else writes to that TextBox. > > > > > > Regards, > > > Ray L. > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> , > > > "himykabibble" <jagboy@> wrote: > > > > > > > > Brad, > > > > > > > > Well it makes me happy to see someone besides me having strange things > > > happening! :-) Hopefully when you get to the bottom of your problem it > will > > > fix mine as well. > > > > > > > > Regards, > > > > Ray L. > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > , > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > Interesting, if I use CompileAndLoadCoff everything works just fine, > it > > > only > > > > > crashes when I use the InvokeAction. > > > > > > > > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user buttons. If you > look > > > at > > > > > the Ccode, it populates the MCodeActions as fires the button > commands as > > > if > > > > > they were any other MCode. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Still, it does not explain why it works for me and not you using the > > > > > CompileAndLoadCoff. > > > > > > > > > > > > > > > > > > > > Then again, I am not using any PComm in my test prog(print.c). I'll > try > > > > > that and get back to you. > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > From: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> ] > > > On > > > > > Behalf Of himykabibble > > > > > Sent: Monday, January 30, 2012 9:21 AM > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > No, I do not have the message event hooked up in my app. (Actually, > > > didn't > > > > > even know how to, but now I do! Cool!). > > > > > > > > > > I am running the C programs using CompileAndLoadCoff. Is > InvokeAction a > > > > > better way to do it? > > > > > > > > > > I've just run into a new problem as well. Two steps forward, one > > > > > backward.... MDI commands, which WERE working fine, now are not. > > > Non-motion > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but motion commands > never > > > > > issue a Completed callback. The move IS completed, I get the status > > > > > callback, then nothing. When I halt the interpreter, by hitting my > > > E-stop > > > > > button, or re-starting the App, THEN I get the completed callback. > So > > > > > something is blocking something there as well. This was working fine > > > until I > > > > > fixed the original PCComm problem. > > > > > > > > > > Regards, > > > > > Ray L. > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > I am wondering if there are some .net memory sharing issues going > on > > > here. > > > > > > > > > > > > > > > > > > > > > > > > I just set one of my user buttons to fire off the print.c program > and > > > I > > > > > get > > > > > > the same result. > > > > > > > > > > > > > > > > > > > > > > > > Do you have the message event wired up? - > > > > > > > > > > > > > > > > > > > > > > > > _Controller.MessageUpdated += new > > > > > > KMConsoleHandler(_Controller_MessageUpdated); > > > > > > > > > > > > > > > > > > > > > > > > I do, and I get the Hello, World message followed by an immediate > > > crash. > > > > > > > > > > > > > > > > > > > > > > > > It is interesting to note that we get the print messages just fine > > > from > > > > > the > > > > > > c# console application. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > So I tried this code in my button event handler as a quick and > dirty > > > > > test:: > > > > > > > > > > > > > > > > > > > > > > > > String TheCFile = _Controller.Interpreter.MainPathRoot + @"\C > > > > > > Programs\KMotionCNC\print.c"; > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1, > > > > > > TheCFile, false)); > > > > > > > > > > > > //Excecute the program we just loaded > > > > > > > > > > > > _Controller.WriteLine("Execute1"); > > > > > > > > > > > > > > > > > > > > > > > > And I get my callbacks from the printf just fine!(no crashes). > > > > > > > > > > > > > > > > > > > > > > > > I looks like InvokeAction with printf's are doing something screwy > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via Interpreter.InvokeAction > as > > > well? > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > [mailto:DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > On > > > > > > Behalf Of himykabibble > > > > > > Sent: Monday, January 30, 2012 1:03 AM > > > > > > To: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > I know this is a stupid question, but is there some interaction or > > > shared > > > > > > resources between the PCComm stuff/Gather buffer and printfs? I > had > > > some > > > > > > printfs in the Home code that I had put in while beating on this > > > thing. I > > > > > > just took them out, and it's now working. Nothing else has > changed. > > > > > printfs > > > > > > still do not come out in the KMotion console after I re-start my > app, > > > so > > > > > > there is something still not completely right, but PCComm is now > > > working, > > > > > so > > > > > > thanks for pointing me in the right direction. I just didn't even > > > really > > > > > > consider the DSP Code, because it's always worked under > KMotionCNC.... > > > > > > > > > > > > What could cause KMotion to be able to talk to the board just > fine, > > > but > > > > > NOT > > > > > > see printfs? For that matter, when in that state, it does not see > DSP > > > > > tasks > > > > > > running either, as indficated as there are no green highlights on > the > > > task > > > > > > IDs next to the editor window. But after re-starting Kmotion, > without > > > > > > restarting my app, all is well. > > > > > > > > > > > > Regards, > > > > > > Ray L. > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > The DSP code is my home function, which works perfectly under > > > > > KMotionCNC. > > > > > > But, just to be sure, I went to a three line program: > > > > > > > > > > > > > > main() > > > > > > > { > > > > > > > printf("Doing MsgBox\n"); > > > > > > > MsgBox("This is my MessageBox", MB_OK); > > > > > > > printf("MsgBox Done\n"); > > > > > > > } > > > > > > > > > > > > > > This gives a different result. The first printf appears every > time. > > > The > > > > > > second one never appears. My app does not crash or behave > strangely in > > > any > > > > > > way that I can see, even if I open and close it several times. > But, if > > > I > > > > > > open KMotion, then open my app, then close it, then re-open it, > > > KMotion > > > > > will > > > > > > still be able to talk to the board, and execute commands from the > > > console, > > > > > > but printfs from the DSP no longer show up in the console window, > > > until I > > > > > > close then re-open KMotion. Does that make any sense? > > > > > > > > > > > > > > I will try to narrow down what in the Home program is > influencing > > > the > > > > > > PCComm stuff. But what could that program be doing that it > wouldn't be > > > > > doing > > > > > > when run under KMotionCNC, where it's always works perfectly?? > > > > > > > > > > > > > > I'll post the code tomorrow. > > > > > > > > > > > > > > Regards, > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > TK <tk@> wrote: > > > > > > > > > > > > > > > > Hi Ray, > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong. But it sounds > more > > > like a > > > > > > problem in your DSP code. Maybe sends garbage to the PC? What does > it > > > do > > > > > > after it sees the persist var cleared? What if you clear it from > the > > > > > KMotion > > > > > > Console instead? Otherwise I can look at if you post all the code. > > > > > > > > > > > > > > > > > > > > > > > > TK > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > > Tom/Brad, > > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you has some suggestions > on > > > how > > > > > to > > > > > > proceed. As long as I don't touch Persist[100], everything works > just > > > > > fine. > > > > > > I can start my app, run programs, exit, connect, disconnect, and > it > > > seems > > > > > to > > > > > > work quite reliably. But if I do a MSG on the DSP side, my PCComm > code > > > > > > correctly processes it, and clears Persist[100], and shortly after > > > that, > > > > > the > > > > > > board "goes missing", and I get the dialog asking me if I want to > run > > > the > > > > > > debugger. Unfortunately, the debugger it wants to run is VS2008, > even > > > > > though > > > > > > I'm running VS2010. If I respond "Yes" to the "debug" prompt, it > opens > > > > > > VS2008, loads the current source file, and that's it. No debugger, > no > > > > > > nothing. That much is, I'm sure, a configuration thing, due to > having > > > both > > > > > > versions installed, but I not only don't know how to fix it, I am > > > > > reluctant > > > > > > to try to get 2008 working in that context, for fear it will screw > up > > > > > 2010, > > > > > > which is what I generally use. I only installed 2008 to be able to > > > build > > > > > > KMotion, and otherwise don't use it. > > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing Persist[100], while > not > > > the > > > > > > actual cause of the problem, is somehow triggering whatever it is > that > > > is > > > > > > going wrong, but I'm totally at a loss to understand what is going > > > wrong, > > > > > or > > > > > > how, and have had no success in trying to narrow it down. If I > comment > > > out > > > > > > the one line that clears Persist[100] after a PCComm command, the > > > problem > > > > > > goes away entirely, and everything works perfectly. If I change > that > > > one > > > > > > line to write *any* other location, like 99, or 101, the failure > > > > > "signature" > > > > > > changes - rather than crashing almost immediately after the > Persist > > > > > location > > > > > > is written, the app continues to run normally until I close it. > > > > > > > > > > > > > > > > > > But, if I then re-start the app without first disconnecting > and > > > > > > reconnecting the board, I get the debug dialog again as soon as > the > > > new > > > > > app > > > > > > instance recognizes the connection is available, and does its > > > > > KM_Controller > > > > > > initialization. I've stepped through all the init code and the > > > > > constructors > > > > > > on that second start-up, and whatever is going wrong is going > wrong > > > AFTER > > > > > > they have all run, and I don't know how to stop it at a point that > > > would > > > > > > give me any useful information about what is going wrong. > > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location used for PComm (I > > > shifted > > > > > > it from Var 100 to 80), the problem follows it to the new > location. So > > > > > it's > > > > > > not the specific location that's at issue, it has to be something > > > > > connected > > > > > > with that functionality. But we know the DSP side works fine, and > the > > > PC > > > > > > side isn't actually *doing* anything, other than writing that one > > > word. So > > > > > > what the heck is really happening? > > > > > > > > > > > > > > > > > > I've double-checked and all my KM_Controller accesses are > > > surrounded > > > > > > with locks, and I'm not doing anything that requires grabbing the > > > token > > > > > (the > > > > > > functions for doing Gather operations do use the token, but those > are > > > > > > commented out now). > > > > > > > > > > > > > > > > > > At the point where it's crashing, there are three threads > > > running: > > > > > > > > > 1) The main app thread > > > > > > > > > 2) A thread running the WCF server for the toolpath display > > > (which > > > > > is > > > > > > basically idle, since the toolpath window is not open) > > > > > > > > > 3) A BackgroundWorker thread doing most of the GUI updates > > > > > > > > > > > > > > > > > > The app thread also has one Timer running, at a 100mSec > rate, > > > mostly > > > > > > for periodically testing the connection, and updating the > "connected" > > > LED > > > > > in > > > > > > the GUI, and showing me the GUI state through a set of on-screen > > > > > checkboxes. > > > > > > This thread is the one that calls the PCComm handler. All Timer > > > methods > > > > > are > > > > > > very simple and lightweight. > > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to post my code if > that > > > would > > > > > > help. I'm truly stuck on this one. > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
|
|
Group: DynoMotion |
Message: 3659 |
From: Brad Murry |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Hello Ray, Maybe wait for next release to reintroduce MainStatus, I’m not sure which .net patch you have. The KM_Axis.CheckEnabled() works for me, you can check it in theKMCNC.net app. -Brad Murry From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On Behalf Of himykabibble Sent: Wednesday, February 01, 2012 11:39 AM To: DynoMotion@yahoogroups.com Subject: [DynoMotion] Re: Need Some Ideas.... Brad,
I removed all use of MainStatus due to problems, which perhaps were ghosts. Should I put it back in?
I'm running about 8 updates/second right now, albeit with a fair amount of "jitter", which is at least tolerable, but it sure looks better at 10-12.
Are the "one off" problems in MainStatus fixed?
Another problem I'm seeing: KMAxes[].CheckEnabled() always returns false. I am assuming if I init and axis with:
KMAxes.Add("XAxis", new KMotion_dotNet.KM_Axis(KMController, 0, "XAxis"));
that this should work:
KMAxes["XAxis"].CheckEnabled()
Regards, Ray L.
--- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@...> wrote: > > Hello Ray, > > > > 20ms is a bit of time, but I think those methods are firing off several USB > calls under the hood, and remember Windows can only *guarantee a ~15ms > process slice tolerance. > > > > The only way to gain much more performance is to manually calculate your > positions from the MainStatus object. > > > > -Brad Murry > > > > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On > Behalf Of himykabibble > Sent: Wednesday, February 01, 2012 9:56 AM > To: DynoMotion@yahoogroups.com > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > I was calling KM_Controller.Interpreter.ReadCurInterpreterPosition() for > EACH axis - not very efficient. So I now call it once per update, and I'm > now seeing 8-10 updates/second - not too bad, and it is visually MUCH > better. Still seems to me 20mSec is a very long time for that call, no? > > Regards, > Ray L. > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > "himykabibble" <jagboy@> wrote: > > > > Here is where my problem lies: > > > > KM_Controller.Interpreter.ReadCurInterpreterPosition() and > KM_Controller.Interpreter.ReadCurMachinePosition() are taking an average of > 20 mSec each. For four axes, that's about 80mSec per update. I also found a > bug in my code that was causing it to do frequent MainStatus reads, but I've > commented that code out for now. My display update code takes, in average, > less than a mSec to run. It is the dotNet calls that are slowing me down. If > I comment out the one line containing the above call, my update rate jumps > from ~4/second up to ~12/second. ALL other code is still running. Most other > dotNet calls, seem to average on the order of 2-3mSec. Are the above calls > not the same ones Brads apps use to get position? Why is it so slow for me? > > > > Regards, > > Ray L. > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> , > "himykabibble" <jagboy@> wrote: > > > > > > BTW - I am no longer seeing ANY hangs, even when I hammer it with > printfs and PCComms. > > > > > > Regards, > > > Ray L. > > > > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > , "himykabibble" <jagboy@> wrote: > > > > > > > > Brad, > > > > > > > > I'm not convinced the slowness I'm seeing is associated with any > particular feature. It seems pretty random. I did find a bug in my > StringGather that caused it to be transferring more data than it should > have, but the overall update timing is slow, and quite variable, so I think > it's either too much traffic, and/or a lot of blocking going on. I'm going > to measure what the update loop time is. It's certainly not close to the > 10/second it should be. > > > > > > > > Is there any problem with asynchronous reads of GUI controls and other > objects associated with the GUI thread? > > > > > > > > I'd be curious what kind of update rate you see if you run the > following on the DSP with a dotNet app. I see the messages coming about > every 1/4 second or so, while under KMotion it looks like about 10/second, > as it should be. > > > > > > > > while(1) > > > > { > > > > int i; > > > > printf )"1\n"); > > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); } > > > > printf )"2\n"); > > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); } > > > > printf )"3\n"); > > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); } > > > > } > > > > > > > > Regards, > > > > Ray L. > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote: > > > > > > > > > > ServiceConsole was not fully implemented, I wonder if that message > pump is > > > > > getting clogged. > > > > > > > > > > > > > > > > > > > > It is now implemented, as I saw it was being used in KMotionCNC. > > > > > > > > > > > > > > > > > > > > Not sure if that is a/the issue though. > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> ] On > > > > > Behalf Of himykabibble > > > > > Sent: Tuesday, January 31, 2012 10:00 PM > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Tom/Brad, > > > > > > > > > > Earlier I was again seeing hangs associated with PCComm and/or > Console > > > > > messages. I added a message queue for the console messages, and it > seems to > > > > > be working solidly again, albeit slow. The GUI will sometimes become > > > > > unresponsive for several seconds (up to 15 at times), then come back > to > > > > > life. Even when it's working, it seems sluggish to me. As I > mentioned, the > > > > > DROs seem to be updating only about 2-3 times per second. If I run a > DSP > > > > > program that does a printf every 2000 time slices, the messages come > out at > > > > > irregular intervals. If I send the messages through PCComm, both the > average > > > > > time, and the irregularity are much greater, with the bulk of time > being > > > > > spent doing the String gathers, which sometimes take as much as 2 or > 3 > > > > > seconds to complete, for a message that is only about a dozen > characters. I > > > > > have to assume I still have some blocking problems. Any suggestions > how to > > > > > find them? > > > > > > > > > > Regards, > > > > > Ray L. > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > , > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > What I'm seeing right now is VERY long times to do the gather in > PCComm to > > > > > retrieve a short String - sometimes on the order of several seconds > to > > > > > retrieve a String that is perhaps a dozen characters. printfs are > coming > > > > > through reliably, and quickly. It seems to me like most operations > that are > > > > > talking to the board are taking an inordinately long time to > complete, > > > > > slowing everything down. I have no doubts this is a threading issue, > but I > > > > > don't know what, and VS2010 seems to provide no support for > examining > > > > > threads... > > > > > > > > > > > > Regards, > > > > > > Ray L. > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > , > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > Unfortunately, my celebration turns out to be a bit premature. > My > > > > > deadlocks are back, after making a few minor changes.... I also > noticed > > > > > today while running on the machine that DRO updates are still very > slow - on > > > > > the order to 2-3 updates/seconds. I suspect there's a lot of waiting > going > > > > > on somewhere in there. > > > > > > > > > > > > > > Regards, > > > > > > > Ray L. > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com> > > > > > , Andrew Ford <ahford@> wrote: > > > > > > > > > > > > > > > > I'm able to get the same hang in Kmotion with a printf every > second or > > > > > so. > > > > > > > > I didn't take too close a look at it in the debugger but it > looks like > > > > > a > > > > > > > > deadlock. I could take a closer look again tonight. > > > > > > > > > > > > > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote: > > > > > > > > > > > > > > > > > ** > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi Ray, > > > > > > > > > > > > > > > > > > BTW the DSP printfs send unsolicited messages to the PC. > Whenever an > > > > > App > > > > > > > > > does a ReadLine from KFLOP the KMotionServer will do a read > from > > > > > KFLOP and > > > > > > > > > may get back the unsolicited message instead of the expected > > > > > response. In > > > > > > > > > that case the unsolicited message received will be sent to > the App > > > > > via the > > > > > > > > > ConsoleCallback and then another read will be performed to > get the > > > > > expected > > > > > > > > > response. > > > > > > > > > > > > > > > > > > So from your description it seems like the crash is somehow > being > > > > > caused > > > > > > > > > by the ConsoleCallback possibly due to a bug in the .Net > interface > > > > > or > > > > > > > > > because the Console is doing something bad in your GUI. > Maybe change > > > > > the > > > > > > > > > ConsoleCallback to just discard the message to help narrow > things > > > > > down. > > > > > > > > > > > > > > > > > > It isn't clear to me if the crash you report having in the > > > > > MarshalPost is > > > > > > > > > before the call or after. > > > > > > > > > > > > > > > > > > Regards > > > > > > > > > TK > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *From:* himykabibble <jagboy@> > > > > > > > > > *To:* DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > *Sent:* Monday, January 30, 2012 4:14 PM > > > > > > > > > > > > > > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > As of last night, thanks to Toms suggestion to look at the > DSP code, > > > > > > > > > PCComm works, as does MDI from the DSP (and I assume most of > the > > > > > other > > > > > > > > > functions, though I haven't tested them all yet). (Mind you, > that > > > > > same DSP > > > > > > > > > code, printfs and all, works perfectly under KMotionCNC...) > PCComm > > > > > was > > > > > > > > > "fixed" by getting rid of the printfs in the DSP code. Put > the > > > > > printfs > > > > > > > > > back, and it starts locking up again (in CheckIsReady() > before, but > > > > > now in > > > > > > > > > MarshalPost within WriteLineReadLine - At least it's a > > > > > dead-consistent > > > > > > > > > failure!). Console messages also work fine, as long as there > are NO > > > > > printfs > > > > > > > > > in the DSP code. > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> > wrote: > > > > > > > > > > > > > > > > > > > > Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I thought the main issue we were working on was the > printf's/PComm > > > > > > > > > issues in > > > > > > > > > > your user programs, has that situation improved at all? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Good that your MDI code works though. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> ] On > > > > > > > > > > Behalf Of himykabibble > > > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM > > > > > > > > > > To: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the > MDI > > > > > problem, > > > > > > > > > but I > > > > > > > > > > still get the hangs in CheckIsRead() when I have the > console > > > > > callback > > > > > > > > > > updating the TextBox, even though it is now also being > invoked. > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > , > > > > > > > > > > "bradodarb" <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I > just > > > > > needed to > > > > > > > > > > invoke them. Kinda weird, you usually only need to invoke > calls to > > > > > your > > > > > > > > > GUI > > > > > > > > > > components, but in my case an HTML button is being > clicked, > > > > > handled by > > > > > > > > > > jscript COM marshaling over to a method in my c# code. > Maybe the > > > > > printf > > > > > > > > > is > > > > > > > > > > using some [STAThread ] component.. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > So Ray, surround your calls in an invoke clause as well > and see > > > > > if it > > > > > > > > > > improves. > > > > > > > > > > > > > > > > > > > > > > Here is a nice tidy way to do it:: > > > > > > > > > > > > > > > > > > > > > > public void UpdateDocument(Action action) > > > > > > > > > > > { > > > > > > > > > > > if (_GuiHost.Parent.InvokeRequired) > > > > > > > > > > > { > > > > > > > > > > > _GuiHost.Parent.Invoke(action); > > > > > > > > > > > } > > > > > > > > > > > else > > > > > > > > > > > { > > > > > > > > > > > action(); > > > > > > > > > > > } > > > > > > > > > > > > > > > > > > > > > > And then in your code that runs the CompileAndLoad, > etc.. :: > > > > > > > > > > > > > > > > > > > > > > UpdateDocument(new Action(delegate() > > > > > > > > > > > { > > > > > > > > > > > //Your existing code inside here > > > > > > > > > > > } > > > > > > > > > > > )); > > > > > > > > > > > > > > > > > > > > > > Let me know if this helps. > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > , > > > > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > You should invoke it to your textbox. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > In related news, I have no issues running any of my > previously > > > > > > > > > > problematic > > > > > > > > > > > > procedures inside a console app.. Only crashes my > winforms > > > > > > > > > browserapp. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > ] > > > > > > > > > > On > > > > > > > > > > > > Behalf Of himykabibble > > > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM > > > > > > > > > > > > To: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > > > > > > > I wired in the console message handler, and I now get > frequent > > > > > > > > > lock-ups. > > > > > > > > > > My > > > > > > > > > > > > handler does nothing more than one line of code that > stuffs > > > > > the > > > > > > > > > String > > > > > > > > > > > > argument into a TextBox. With that one line commented > out, all > > > > > is > > > > > > > > > good. > > > > > > > > > > But > > > > > > > > > > > > if I uncomment that one line, then I get frequent > hangs - the > > > > > app > > > > > > > > > just > > > > > > > > > > locks > > > > > > > > > > > > up. No errors, exceptions, or anything but the GUI > stops > > > > > responding > > > > > > > > > > > > entirely. The callback does work as it should, until > the app > > > > > locks > > > > > > > > > up. > > > > > > > > > > Is > > > > > > > > > > > > this a threading thing? Nobody else writes to that > TextBox. > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > > > > "himykabibble" <jagboy@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > > > > > > > > > Well it makes me happy to see someone besides me > having > > > > > strange > > > > > > > > > things > > > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of > your > > > > > problem > > > > > > > > > it > > > > > > > > > > will > > > > > > > > > > > > fix mine as well. > > > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > <mailto:%0b> > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > , > > > > > > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff > everything works > > > > > just > > > > > > > > > fine, > > > > > > > > > > it > > > > > > > > > > > > only > > > > > > > > > > > > > > crashes when I use the InvokeAction. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user > > > > > buttons. If > > > > > > > > > you > > > > > > > > > > look > > > > > > > > > > > > at > > > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires > the > > > > > button > > > > > > > > > > commands as > > > > > > > > > > > > if > > > > > > > > > > > > > > they were any other MCode. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Still, it does not explain why it works for me and > not you > > > > > using > > > > > > > > > the > > > > > > > > > > > > > > CompileAndLoadCoff. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Then again, I am not using any PComm in my test > > > > > prog(print.c). > > > > > > > > > I'll > > > > > > > > > > try > > > > > > > > > > > > > > that and get back to you. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > <mailto:%0b> > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > > > > > > > On > > > > > > > > > > > > > > Behalf Of himykabibble > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b> > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Brad, > > > > > > > > > > > > > > > > > > > > > > > > > > > > No, I do not have the message event hooked up in > my app. > > > > > > > > > (Actually, > > > > > > > > > > > > didn't > > > > > > > > > > > > > > even know how to, but now I do! Cool!). > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am running the C programs using > CompileAndLoadCoff. Is > > > > > > > > > > InvokeAction a > > > > > > > > > > > > > > better way to do it? > > > > > > > > > > > > > > > > > > > > > > > > > > > > I've just run into a new problem as well. Two > steps > > > > > forward, one > > > > > > > > > > > > > > backward.... MDI commands, which WERE working > fine, now > > > > > are not. > > > > > > > > > > > > Non-motion > > > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but > motion > > > > > > > > > commands > > > > > > > > > > never > > > > > > > > > > > > > > issue a Completed callback. The move IS completed, > I get > > > > > the > > > > > > > > > status > > > > > > > > > > > > > > callback, then nothing. When I halt the > interpreter, by > > > > > hitting > > > > > > > > > my > > > > > > > > > > > > E-stop > > > > > > > > > > > > > > button, or re-starting the App, THEN I get the > completed > > > > > > > > > callback. > > > > > > > > > > So > > > > > > > > > > > > > > something is blocking something there as well. > This was > > > > > working > > > > > > > > > fine > > > > > > > > > > > > until I > > > > > > > > > > > > > > fixed the original PCComm problem. > > > > > > > > > > > > > > > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > > Ray L. > > > > > > > > > > > > > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > <mailto:%0b> > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> , > > > > > > > > > > > > > > Brad Murry <bradodarb@> wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hello Ray, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I am wondering if there are some .net memory > sharing > > > > > issues > > > > > > > > > going > > > > > > > > > > on > > > > > > > > > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I just set one of my user buttons to fire off > the > > > > > print.c > > > > > > > > > program > > > > > > > > > > and > > > > > > > > > > > > I > > > > > > > > > > > > > > get > > > > > > > > > > > > > > > the same result. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Do you have the message event wired up? - > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _Controller.MessageUpdated += new > > > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I do, and I get the Hello, World message > followed by an > > > > > > > > > immediate > > > > > > > > > > > > crash. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > It is interesting to note that we get the print > messages > > > > > just > > > > > > > > > fine > > > > > > > > > > > > from > > > > > > > > > > > > > > the > > > > > > > > > > > > > > > c# console application. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > So I tried this code in my button event handler > as a > > > > > quick and > > > > > > > > > > dirty > > > > > > > > > > > > > > test:: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > String TheCFile = > _Controller.Interpreter.MainPathRoot + > > > > > @"\C > > > > > > > > > > > > > > > Programs\KMotionCNC\print.c"; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Console.WriteLine(_Controller.CompileAndLoadCoff(1, > > > > > > > > > > > > > > > TheCFile, false)); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > //Excecute the program we just loaded > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _Controller.WriteLine("Execute1"); > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > And I get my callbacks from the printf just > fine!(no > > > > > crashes). > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I looks like InvokeAction with printf's are > doing > > > > > something > > > > > > > > > screwy > > > > > > > > > > > > here. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via > > > > > > > > > Interpreter.InvokeAction > > > > > > > > > > as > > > > > > > > > > > > well? > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -Brad Murry > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > <mailto:%0b> > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ] > > > > > > > > > > > > > > On > > > > > > > > > > > > > > > Behalf Of himykabibble > > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM > > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com > <mailto:DynoMotion%40yahoogroups.com> > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: > <mailto:%0b> > > > > > > > > > DynoMotion%40yahoogroups.com> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> > > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas.... > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Tom, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I know this is a stupid question, but is there > some > > > > > > > > > interaction or > > > > > > > > > > > > shared > > > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer > and > > > > > printfs? I > > > > > > > > > > had > > > > > > > > > > > > some > > > > > > > > > > > > > > > printfs in the Home code that I had put in while > beating > > > > > on > > > > > > > > > this > > > > > > > > > > > > thing. I > > > > > > > > > > > > > > > just took them out, and it's now working. > Nothing else > > > > > has > > > > > > > > > > changed. > > > > > > > > > > > > > > printfs > > > > > > > > > > > > > > > still do not come out in the KMotion console > after I > > > > > re-start > > > > > > > > > my > > > > > > > > > > app, > > > > > > > > > > > > so > > > > > > > > > > > > > > > there is something still not completely right, > but > > > > > PCComm is > > > > > > > > > now > > > > > > > > > > > > working, > > > > > > > > > > > > > > so > > > > > > > > > > >
(Message over 64 KB, truncated)
|
|
Group: DynoMotion |
Message: 3660 |
From: Tom Kerekes |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Hi Andrew,
(again heldup as spam. I trimmed the message maybe that will help).
Yes please let me know what you find. How long does it take to happen? I haven't seen a problem like this. I still am not totally clear what you are doing. Are you running a .NET program at the same time as KMotion.
Thanks
TK
Group: DynoMotion |
Message: 3661 |
From: Tom Kerekes |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Hi Ray,
Yes I think you definitely want to eventually use MainStatus. We're trying to put together a release with all the latest fixes. What we have now is:
But it is a work in progress so you should probably wait.
Regards
TK
Group: DynoMotion |
Message: 3662 |
From: himykabibble |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
Tom,
I will be waiting with bated breath.... I think using MainStatus will get me that last little bump in update performance that should make the display really smooth. It's not *bad* right now, but it's not great either.
Regards,
Ray L.
--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Ray,
> Â
> Yes I think you definitely want to eventually use MainStatus. We're trying to put together a release with all the latest fixes.  What we have now is:
> Â
> http://www.dynomotion.com/Software/KMotion429x.exe
> Â
> But it is a work in progress so you should probably wait.
> Â
> Regards
> TKÂ
>
>
> ________________________________
> From: himykabibble <jagboy@...>
> To: DynoMotion@yahoogroups.com
> Sent: Wednesday, February 1, 2012 10:39 AM
> Subject: [DynoMotion] Re: Need Some Ideas....
>
>
> Â
> Brad,
>
> I removed all use of MainStatus due to problems, which perhaps were ghosts. Should I put it back in?
>
> I'm running about 8 updates/second right now, albeit with a fair amount of "jitter", which is at least tolerable, but it sure looks better at 10-12.
>
> Are the "one off" problems in MainStatus fixed?
>
> Another problem I'm seeing: KMAxes[].CheckEnabled() always returns false. I am assuming if I init and axis with:
>
> KMAxes.Add("XAxis", new KMotion_dotNet.KM_Axis(KMController, 0, "XAxis"));
>
> that this should work:
>
> KMAxes["XAxis"].CheckEnabled()
>
> Regards,
> Ray L.
>
> --- In DynoMotion@yahoogroups.com, Brad Murry <bradodarb@> wrote:
> >
> > Hello Ray,
> >
> >
> >
> > 20ms is a bit of time, but I think those methods are firing off several USB
> > calls under the hood, and remember Windows can only *guarantee a ~15ms
> > process slice tolerance.
> >
> >
> >
> > The only way to gain much more performance is to manually calculate your
> > positions from the MainStatus object.
> >
> >
> >
> > -Brad Murry
> >
> >
> >
> > From: DynoMotion@yahoogroups.com [mailto:DynoMotion@yahoogroups.com] On
> > Behalf Of himykabibble
> > Sent: Wednesday, February 01, 2012 9:56 AM
> > To: DynoMotion@yahoogroups.com
> > Subject: [DynoMotion] Re: Need Some Ideas....
> >
> >
> >
> >
> >
> > I was calling KM_Controller.Interpreter.ReadCurInterpreterPosition() for
> > EACH axis - not very efficient. So I now call it once per update, and I'm
> > now seeing 8-10 updates/second - not too bad, and it is visually MUCH
> > better. Still seems to me 20mSec is a very long time for that call, no?
> >
> > Regards,
> > Ray L.
> >
> > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > "himykabibble" <jagboy@> wrote:
> > >
> > > Here is where my problem lies:
> > >
> > > KM_Controller.Interpreter.ReadCurInterpreterPosition() and
> > KM_Controller.Interpreter.ReadCurMachinePosition() are taking an average of
> > 20 mSec each. For four axes, that's about 80mSec per update. I also found a
> > bug in my code that was causing it to do frequent MainStatus reads, but I've
> > commented that code out for now. My display update code takes, in average,
> > less than a mSec to run. It is the dotNet calls that are slowing me down. If
> > I comment out the one line containing the above call, my update rate jumps
> > from ~4/second up to ~12/second. ALL other code is still running. Most other
> > dotNet calls, seem to average on the order of 2-3mSec. Are the above calls
> > not the same ones Brads apps use to get position? Why is it so slow for me?
> > >
> > > Regards,
> > > Ray L.
> > >
> > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com> ,
> > "himykabibble" <jagboy@> wrote:
> > > >
> > > > BTW - I am no longer seeing ANY hangs, even when I hammer it with
> > printfs and PCComms.
> > > >
> > > > Regards,
> > > > Ray L.
> > > >
> > > > --- In DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > , "himykabibble" <jagboy@> wrote:
> > > > >
> > > > > Brad,
> > > > >
> > > > > I'm not convinced the slowness I'm seeing is associated with any
> > particular feature. It seems pretty random. I did find a bug in my
> > StringGather that caused it to be transferring more data than it should
> > have, but the overall update timing is slow, and quite variable, so I think
> > it's either too much traffic, and/or a lot of blocking going on. I'm going
> > to measure what the update loop time is. It's certainly not close to the
> > 10/second it should be.
> > > > >
> > > > > Is there any problem with asynchronous reads of GUI controls and other
> > objects associated with the GUI thread?
> > > > >
> > > > > I'd be curious what kind of update rate you see if you run the
> > following on the DSP with a dotNet app. I see the messages coming about
> > every 1/4 second or so, while under KMotion it looks like about 10/second,
> > as it should be.
> > > > >
> > > > > while(1)
> > > > > {
> > > > > int i;
> > > > > printf )"1\n");
> > > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > > > printf )"2\n");
> > > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > > > printf )"3\n");
> > > > > for (i=1000; i>0l i--) { WaitNextTimeSlice(); }
> > > > > }
> > > > >
> > > > > Regards,
> > > > > Ray L.
> > > > >
> > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@> wrote:
> > > > > >
> > > > > > ServiceConsole was not fully implemented, I wonder if that message
> > pump is
> > > > > > getting clogged.
> > > > > >
> > > > > >
> > > > > >
> > > > > > It is now implemented, as I saw it was being used in KMotionCNC.
> > > > > >
> > > > > >
> > > > > >
> > > > > > Not sure if that is a/the issue though.
> > > > > >
> > > > > >
> > > > > >
> > > > > > -Brad Murry
> > > > > >
> > > > > >
> > > > > >
> > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > > Behalf Of himykabibble
> > > > > > Sent: Tuesday, January 31, 2012 10:00 PM
> > > > > > To: DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> >
> > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > Tom/Brad,
> > > > > >
> > > > > > Earlier I was again seeing hangs associated with PCComm and/or
> > Console
> > > > > > messages. I added a message queue for the console messages, and it
> > seems to
> > > > > > be working solidly again, albeit slow. The GUI will sometimes become
> > > > > > unresponsive for several seconds (up to 15 at times), then come back
> > to
> > > > > > life. Even when it's working, it seems sluggish to me. As I
> > mentioned, the
> > > > > > DROs seem to be updating only about 2-3 times per second. If I run a
> > DSP
> > > > > > program that does a printf every 2000 time slices, the messages come
> > out at
> > > > > > irregular intervals. If I send the messages through PCComm, both the
> > average
> > > > > > time, and the irregularity are much greater, with the bulk of time
> > being
> > > > > > spent doing the String gathers, which sometimes take as much as 2 or
> > 3
> > > > > > seconds to complete, for a message that is only about a dozen
> > characters. I
> > > > > > have to assume I still have some blocking problems. Any suggestions
> > how to
> > > > > > find them?
> > > > > >
> > > > > > Regards,
> > > > > > Ray L.
> > > > > >
> > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > ,
> > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > >
> > > > > > > What I'm seeing right now is VERY long times to do the gather in
> > PCComm to
> > > > > > retrieve a short String - sometimes on the order of several seconds
> > to
> > > > > > retrieve a String that is perhaps a dozen characters. printfs are
> > coming
> > > > > > through reliably, and quickly. It seems to me like most operations
> > that are
> > > > > > talking to the board are taking an inordinately long time to
> > complete,
> > > > > > slowing everything down. I have no doubts this is a threading issue,
> > but I
> > > > > > don't know what, and VS2010 seems to provide no support for
> > examining
> > > > > > threads...
> > > > > > >
> > > > > > > Regards,
> > > > > > > Ray L.
> > > > > > >
> > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > ,
> > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > >
> > > > > > > > Unfortunately, my celebration turns out to be a bit premature.
> > My
> > > > > > deadlocks are back, after making a few minor changes.... I also
> > noticed
> > > > > > today while running on the machine that DRO updates are still very
> > slow - on
> > > > > > the order to 2-3 updates/seconds. I suspect there's a lot of waiting
> > going
> > > > > > on somewhere in there.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Ray L.
> > > > > > > >
> > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com> <mailto:DynoMotion%40yahoogroups.com>
> > > > > > , Andrew Ford <ahford@> wrote:
> > > > > > > > >
> > > > > > > > > I'm able to get the same hang in Kmotion with a printf every
> > second or
> > > > > > so.
> > > > > > > > > I didn't take too close a look at it in the debugger but it
> > looks like
> > > > > > a
> > > > > > > > > deadlock. I could take a closer look again tonight.
> > > > > > > > >
> > > > > > > > > On Mon, Jan 30, 2012 at 4:53 PM, Tom Kerekes <tk@> wrote:
> > > > > > > > >
> > > > > > > > > > **
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Hi Ray,
> > > > > > > > > >
> > > > > > > > > > BTW the DSP printfs send unsolicited messages to the PC.
> > Whenever an
> > > > > > App
> > > > > > > > > > does a ReadLine from KFLOP the KMotionServer will do a read
> > from
> > > > > > KFLOP and
> > > > > > > > > > may get back the unsolicited message instead of the expected
> > > > > > response. In
> > > > > > > > > > that case the unsolicited message received will be sent to
> > the App
> > > > > > via the
> > > > > > > > > > ConsoleCallback and then another read will be performed to
> > get the
> > > > > > expected
> > > > > > > > > > response.
> > > > > > > > > >
> > > > > > > > > > So from your description it seems like the crash is somehow
> > being
> > > > > > caused
> > > > > > > > > > by the ConsoleCallback possibly due to a bug in the .Net
> > interface
> > > > > > or
> > > > > > > > > > because the Console is doing something bad in your GUI.
> > Maybe change
> > > > > > the
> > > > > > > > > > ConsoleCallback to just discard the message to help narrow
> > things
> > > > > > down.
> > > > > > > > > >
> > > > > > > > > > It isn't clear to me if the crash you report having in the
> > > > > > MarshalPost is
> > > > > > > > > > before the call or after.
> > > > > > > > > >
> > > > > > > > > > Regards
> > > > > > > > > > TK
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > *From:* himykabibble <jagboy@>
> > > > > > > > > > *To:* DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > *Sent:* Monday, January 30, 2012 4:14 PM
> > > > > > > > > >
> > > > > > > > > > *Subject:* [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Brad,
> > > > > > > > > >
> > > > > > > > > > As of last night, thanks to Toms suggestion to look at the
> > DSP code,
> > > > > > > > > > PCComm works, as does MDI from the DSP (and I assume most of
> > the
> > > > > > other
> > > > > > > > > > functions, though I haven't tested them all yet). (Mind you,
> > that
> > > > > > same DSP
> > > > > > > > > > code, printfs and all, works perfectly under KMotionCNC...)
> > PCComm
> > > > > > was
> > > > > > > > > > "fixed" by getting rid of the printfs in the DSP code. Put
> > the
> > > > > > printfs
> > > > > > > > > > back, and it starts locking up again (in CheckIsReady()
> > before, but
> > > > > > now in
> > > > > > > > > > MarshalPost within WriteLineReadLine - At least it's a
> > > > > > dead-consistent
> > > > > > > > > > failure!). Console messages also work fine, as long as there
> > are NO
> > > > > > printfs
> > > > > > > > > > in the DSP code.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Ray L.
> > > > > > > > > >
> > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> , Brad Murry <bradodarb@>
> > wrote:
> > > > > > > > > > >
> > > > > > > > > > > Ray,
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I thought the main issue we were working on was the
> > printf's/PComm
> > > > > > > > > > issues in
> > > > > > > > > > > your user programs, has that situation improved at all?
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Good that your MDI code works though.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > -Brad
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > [mailto:DynoMotion@yahoogroups.com <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> ] On
> > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > Sent: Monday, January 30, 2012 11:24 AM
> > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Brad,
> > > > > > > > > > >
> > > > > > > > > > > Putting invokes on my CompileAndLoad calls has fixed the
> > MDI
> > > > > > problem,
> > > > > > > > > > but I
> > > > > > > > > > > still get the hangs in CheckIsRead() when I have the
> > console
> > > > > > callback
> > > > > > > > > > > updating the TextBox, even though it is now also being
> > invoked.
> > > > > > > > > > >
> > > > > > > > > > > Regards,
> > > > > > > > > > > Ray L.
> > > > > > > > > > >
> > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > ,
> > > > > > > > > > > "bradodarb" <bradodarb@> wrote:
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > OK, now I can reliably run my InvokeAction() calls. I
> > just
> > > > > > needed to
> > > > > > > > > > > invoke them. Kinda weird, you usually only need to invoke
> > calls to
> > > > > > your
> > > > > > > > > > GUI
> > > > > > > > > > > components, but in my case an HTML button is being
> > clicked,
> > > > > > handled by
> > > > > > > > > > > jscript COM marshaling over to a method in my c# code.
> > Maybe the
> > > > > > printf
> > > > > > > > > > is
> > > > > > > > > > > using some [STAThread ] component..
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > So Ray, surround your calls in an invoke clause as well
> > and see
> > > > > > if it
> > > > > > > > > > > improves.
> > > > > > > > > > > >
> > > > > > > > > > > > Here is a nice tidy way to do it::
> > > > > > > > > > > >
> > > > > > > > > > > > public void UpdateDocument(Action action)
> > > > > > > > > > > > {
> > > > > > > > > > > > if (_GuiHost.Parent.InvokeRequired)
> > > > > > > > > > > > {
> > > > > > > > > > > > _GuiHost.Parent.Invoke(action);
> > > > > > > > > > > > }
> > > > > > > > > > > > else
> > > > > > > > > > > > {
> > > > > > > > > > > > action();
> > > > > > > > > > > > }
> > > > > > > > > > > >
> > > > > > > > > > > > And then in your code that runs the CompileAndLoad,
> > etc.. ::
> > > > > > > > > > > >
> > > > > > > > > > > > UpdateDocument(new Action(delegate()
> > > > > > > > > > > > {
> > > > > > > > > > > > //Your existing code inside here
> > > > > > > > > > > > }
> > > > > > > > > > > > ));
> > > > > > > > > > > >
> > > > > > > > > > > > Let me know if this helps.
> > > > > > > > > > > >
> > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > >
> > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > ,
> > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > You should invoke it to your textbox.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > In related news, I have no issues running any of my
> > previously
> > > > > > > > > > > problematic
> > > > > > > > > > > > > procedures inside a console app.. Only crashes my
> > winforms
> > > > > > > > > > browserapp.
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > ]
> > > > > > > > > > > On
> > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > Sent: Monday, January 30, 2012 10:18 AM
> > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > >
> > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > Brad,
> > > > > > > > > > > > >
> > > > > > > > > > > > > I wired in the console message handler, and I now get
> > frequent
> > > > > > > > > > lock-ups.
> > > > > > > > > > > My
> > > > > > > > > > > > > handler does nothing more than one line of code that
> > stuffs
> > > > > > the
> > > > > > > > > > String
> > > > > > > > > > > > > argument into a TextBox. With that one line commented
> > out, all
> > > > > > is
> > > > > > > > > > good.
> > > > > > > > > > > But
> > > > > > > > > > > > > if I uncomment that one line, then I get frequent
> > hangs - the
> > > > > > app
> > > > > > > > > > just
> > > > > > > > > > > locks
> > > > > > > > > > > > > up. No errors, exceptions, or anything but the GUI
> > stops
> > > > > > responding
> > > > > > > > > > > > > entirely. The callback does work as it should, until
> > the app
> > > > > > locks
> > > > > > > > > > up.
> > > > > > > > > > > Is
> > > > > > > > > > > > > this a threading thing? Nobody else writes to that
> > TextBox.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Brad,
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Well it makes me happy to see someone besides me
> > having
> > > > > > strange
> > > > > > > > > > things
> > > > > > > > > > > > > happening! :-) Hopefully when you get to the bottom of
> > your
> > > > > > problem
> > > > > > > > > > it
> > > > > > > > > > > will
> > > > > > > > > > > > > fix mine as well.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > <mailto:%0b>
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > ,
> > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Interesting, if I use CompileAndLoadCoff
> > everything works
> > > > > > just
> > > > > > > > > > fine,
> > > > > > > > > > > it
> > > > > > > > > > > > > only
> > > > > > > > > > > > > > > crashes when I use the InvokeAction.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > InvokeAction is what KMotionCNC uses for it's user
> > > > > > buttons. If
> > > > > > > > > > you
> > > > > > > > > > > look
> > > > > > > > > > > > > at
> > > > > > > > > > > > > > > the Ccode, it populates the MCodeActions as fires
> > the
> > > > > > button
> > > > > > > > > > > commands as
> > > > > > > > > > > > > if
> > > > > > > > > > > > > > > they were any other MCode.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Still, it does not explain why it works for me and
> > not you
> > > > > > using
> > > > > > > > > > the
> > > > > > > > > > > > > > > CompileAndLoadCoff.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Then again, I am not using any PComm in my test
> > > > > > prog(print.c).
> > > > > > > > > > I'll
> > > > > > > > > > > try
> > > > > > > > > > > > > > > that and get back to you.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > -Brad
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > <mailto:%0b>
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > On
> > > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 9:21 AM
> > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto: <mailto:%0b>
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Brad,
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > No, I do not have the message event hooked up in
> > my app.
> > > > > > > > > > (Actually,
> > > > > > > > > > > > > didn't
> > > > > > > > > > > > > > > even know how to, but now I do! Cool!).
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I am running the C programs using
> > CompileAndLoadCoff. Is
> > > > > > > > > > > InvokeAction a
> > > > > > > > > > > > > > > better way to do it?
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > I've just run into a new problem as well. Two
> > steps
> > > > > > forward, one
> > > > > > > > > > > > > > > backward.... MDI commands, which WERE working
> > fine, now
> > > > > > are not.
> > > > > > > > > > > > > Non-motion
> > > > > > > > > > > > > > > commands work fine (G20/21, M3-5, M7-9, etc.), but
> > motion
> > > > > > > > > > commands
> > > > > > > > > > > never
> > > > > > > > > > > > > > > issue a Completed callback. The move IS completed,
> > I get
> > > > > > the
> > > > > > > > > > status
> > > > > > > > > > > > > > > callback, then nothing. When I halt the
> > interpreter, by
> > > > > > hitting
> > > > > > > > > > my
> > > > > > > > > > > > > E-stop
> > > > > > > > > > > > > > > button, or re-starting the App, THEN I get the
> > completed
> > > > > > > > > > callback.
> > > > > > > > > > > So
> > > > > > > > > > > > > > > something is blocking something there as well.
> > This was
> > > > > > working
> > > > > > > > > > fine
> > > > > > > > > > > > > until I
> > > > > > > > > > > > > > > fixed the original PCComm problem.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > <mailto:%0b>
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > Brad Murry <bradodarb@> wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Hello Ray,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I am wondering if there are some .net memory
> > sharing
> > > > > > issues
> > > > > > > > > > going
> > > > > > > > > > > on
> > > > > > > > > > > > > here.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I just set one of my user buttons to fire off
> > the
> > > > > > print.c
> > > > > > > > > > program
> > > > > > > > > > > and
> > > > > > > > > > > > > I
> > > > > > > > > > > > > > > get
> > > > > > > > > > > > > > > > the same result.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Do you have the message event wired up? -
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > _Controller.MessageUpdated += new
> > > > > > > > > > > > > > > > KMConsoleHandler(_Controller_MessageUpdated);
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I do, and I get the Hello, World message
> > followed by an
> > > > > > > > > > immediate
> > > > > > > > > > > > > crash.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > It is interesting to note that we get the print
> > messages
> > > > > > just
> > > > > > > > > > fine
> > > > > > > > > > > > > from
> > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > c# console application.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > So I tried this code in my button event handler
> > as a
> > > > > > quick and
> > > > > > > > > > > dirty
> > > > > > > > > > > > > > > test::
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > String TheCFile =
> > _Controller.Interpreter.MainPathRoot +
> > > > > > @"\C
> > > > > > > > > > > > > > > > Programs\KMotionCNC\print.c";
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > Console.WriteLine(_Controller.CompileAndLoadCoff(1,
> > > > > > > > > > > > > > > > TheCFile, false));
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > //Excecute the program we just loaded
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > _Controller.WriteLine("Execute1");
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > And I get my callbacks from the printf just
> > fine!(no
> > > > > > crashes).
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I looks like InvokeAction with printf's are
> > doing
> > > > > > something
> > > > > > > > > > screwy
> > > > > > > > > > > > > here.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Ray- Are you invoking your cprogram via
> > > > > > > > > > Interpreter.InvokeAction
> > > > > > > > > > > as
> > > > > > > > > > > > > well?
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > -Brad Murry
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > From: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > <mailto:%0b>
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > [mailto:DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ]
> > > > > > > > > > > > > > > On
> > > > > > > > > > > > > > > > Behalf Of himykabibble
> > > > > > > > > > > > > > > > Sent: Monday, January 30, 2012 1:03 AM
> > > > > > > > > > > > > > > > To: DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> <mailto:
> > <mailto:%0b>
> > > > > > > > > > DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > > Subject: [DynoMotion] Re: Need Some Ideas....
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I know this is a stupid question, but is there
> > some
> > > > > > > > > > interaction or
> > > > > > > > > > > > > shared
> > > > > > > > > > > > > > > > resources between the PCComm stuff/Gather buffer
> > and
> > > > > > printfs? I
> > > > > > > > > > > had
> > > > > > > > > > > > > some
> > > > > > > > > > > > > > > > printfs in the Home code that I had put in while
> > beating
> > > > > > on
> > > > > > > > > > this
> > > > > > > > > > > > > thing. I
> > > > > > > > > > > > > > > > just took them out, and it's now working.
> > Nothing else
> > > > > > has
> > > > > > > > > > > changed.
> > > > > > > > > > > > > > > printfs
> > > > > > > > > > > > > > > > still do not come out in the KMotion console
> > after I
> > > > > > re-start
> > > > > > > > > > my
> > > > > > > > > > > app,
> > > > > > > > > > > > > so
> > > > > > > > > > > > > > > > there is something still not completely right,
> > but
> > > > > > PCComm is
> > > > > > > > > > now
> > > > > > > > > > > > > working,
> > > > > > > > > > > > > > > so
> > > > > > > > > > > > > > > > thanks for pointing me in the right direction. I
> > just
> > > > > > didn't
> > > > > > > > > > even
> > > > > > > > > > > > > really
> > > > > > > > > > > > > > > > consider the DSP Code, because it's always
> > worked under
> > > > > > > > > > > KMotionCNC....
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > What could cause KMotion to be able to talk to
> > the board
> > > > > > just
> > > > > > > > > > > fine,
> > > > > > > > > > > > > but
> > > > > > > > > > > > > > > NOT
> > > > > > > > > > > > > > > > see printfs? For that matter, when in that
> > state, it
> > > > > > does not
> > > > > > > > > > see
> > > > > > > > > > > DSP
> > > > > > > > > > > > > > > tasks
> > > > > > > > > > > > > > > > running either, as indficated as there are no
> > green
> > > > > > highlights
> > > > > > > > > > on
> > > > > > > > > > > the
> > > > > > > > > > > > > task
> > > > > > > > > > > > > > > > IDs next to the editor window. But after
> > re-starting
> > > > > > Kmotion,
> > > > > > > > > > > without
> > > > > > > > > > > > > > > > restarting my app, all is well.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > > "himykabibble" <jagboy@> wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Tom,
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > The DSP code is my home function, which works
> > > > > > perfectly under
> > > > > > > > > > > > > > > KMotionCNC.
> > > > > > > > > > > > > > > > But, just to be sure, I went to a three line
> > program:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > main()
> > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > > printf("Doing MsgBox\n");
> > > > > > > > > > > > > > > > > MsgBox("This is my MessageBox", MB_OK);
> > > > > > > > > > > > > > > > > printf("MsgBox Done\n");
> > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > This gives a different result. The first
> > printf
> > > > > > appears every
> > > > > > > > > > > time.
> > > > > > > > > > > > > The
> > > > > > > > > > > > > > > > second one never appears. My app does not crash
> > or
> > > > > > behave
> > > > > > > > > > > strangely in
> > > > > > > > > > > > > any
> > > > > > > > > > > > > > > > way that I can see, even if I open and close it
> > several
> > > > > > times.
> > > > > > > > > > > But, if
> > > > > > > > > > > > > I
> > > > > > > > > > > > > > > > open KMotion, then open my app, then close it,
> > then
> > > > > > re-open it,
> > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > > will
> > > > > > > > > > > > > > > > still be able to talk to the board, and execute
> > commands
> > > > > > from
> > > > > > > > > > the
> > > > > > > > > > > > > console,
> > > > > > > > > > > > > > > > but printfs from the DSP no longer show up in
> > the
> > > > > > console
> > > > > > > > > > window,
> > > > > > > > > > > > > until I
> > > > > > > > > > > > > > > > close then re-open KMotion. Does that make any
> > sense?
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I will try to narrow down what in the Home
> > program is
> > > > > > > > > > > influencing
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > PCComm stuff. But what could that program be
> > doing that
> > > > > > it
> > > > > > > > > > > wouldn't be
> > > > > > > > > > > > > > > doing
> > > > > > > > > > > > > > > > when run under KMotionCNC, where it's always
> > works
> > > > > > perfectly??
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I'll post the code tomorrow.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > --- In DynoMotion@yahoogroups.com
> > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com>
> > > > > > > > > > > > > > > <mailto:DynoMotion%40yahoogroups.com> ,
> > > > > > > > > > > > > > > > TK <tk@> wrote:
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Hi Ray,
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > Nothing jumps out to me what could be wrong.
> > But it
> > > > > > sounds
> > > > > > > > > > > more
> > > > > > > > > > > > > like a
> > > > > > > > > > > > > > > > problem in your DSP code. Maybe sends garbage to
> > the PC?
> > > > > > What
> > > > > > > > > > does
> > > > > > > > > > > it
> > > > > > > > > > > > > do
> > > > > > > > > > > > > > > > after it sees the persist var cleared? What if
> > you clear
> > > > > > it
> > > > > > > > > > from
> > > > > > > > > > > the
> > > > > > > > > > > > > > > KMotion
> > > > > > > > > > > > > > > > Console instead? Otherwise I can look at if you
> > post all
> > > > > > the
> > > > > > > > > > code.
> > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > TK
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > On Jan 29, 2012, at 10:31 PM, "himykabibble"
> > > > > > <jagboy@>
> > > > > > > > > > wrote:
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Tom/Brad,
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > I'm out of ideas, and hoping one of you
> > has some
> > > > > > > > > > suggestions
> > > > > > > > > > > on
> > > > > > > > > > > > > how
> > > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > > proceed. As long as I don't touch Persist[100],
> > > > > > everything
> > > > > > > > > > works
> > > > > > > > > > > just
> > > > > > > > > > > > > > > fine.
> > > > > > > > > > > > > > > > I can start my app, run programs, exit, connect,
> > > > > > disconnect,
> > > > > > > > > > and
> > > > > > > > > > > it
> > > > > > > > > > > > > seems
> > > > > > > > > > > > > > > to
> > > > > > > > > > > > > > > > work quite reliably. But if I do a MSG on the
> > DSP side,
> > > > > > my
> > > > > > > > > > PCComm
> > > > > > > > > > > code
> > > > > > > > > > > > > > > > correctly processes it, and clears Persist[100],
> > and
> > > > > > shortly
> > > > > > > > > > after
> > > > > > > > > > > > > that,
> > > > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > board "goes missing", and I get the dialog
> > asking me if
> > > > > > I want
> > > > > > > > > > to
> > > > > > > > > > > run
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > debugger. Unfortunately, the debugger it wants
> > to run is
> > > > > > > > > > VS2008,
> > > > > > > > > > > even
> > > > > > > > > > > > > > > though
> > > > > > > > > > > > > > > > I'm running VS2010. If I respond "Yes" to the
> > "debug"
> > > > > > prompt,
> > > > > > > > > > it
> > > > > > > > > > > opens
> > > > > > > > > > > > > > > > VS2008, loads the current source file, and
> > that's it. No
> > > > > > > > > > debugger,
> > > > > > > > > > > no
> > > > > > > > > > > > > > > > nothing. That much is, I'm sure, a configuration
> > thing,
> > > > > > due to
> > > > > > > > > > > having
> > > > > > > > > > > > > both
> > > > > > > > > > > > > > > > versions installed, but I not only don't know
> > how to fix
> > > > > > it, I
> > > > > > > > > > am
> > > > > > > > > > > > > > > reluctant
> > > > > > > > > > > > > > > > to try to get 2008 working in that context, for
> > fear it
> > > > > > will
> > > > > > > > > > screw
> > > > > > > > > > > up
> > > > > > > > > > > > > > > 2010,
> > > > > > > > > > > > > > > > which is what I generally use. I only installed
> > 2008 to
> > > > > > be
> > > > > > > > > > able to
> > > > > > > > > > > > > build
> > > > > > > > > > > > > > > > KMotion, and otherwise don't use it.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Anyway, I am convinced it is clearing
> > > > > > Persist[100], while
> > > > > > > > > > > not
> > > > > > > > > > > > > the
> > > > > > > > > > > > > > > > actual cause of the problem, is somehow
> > triggering
> > > > > > whatever it
> > > > > > > > > > is
> > > > > > > > > > > that
> > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > going wrong, but I'm totally at a loss to
> > understand
> > > > > > what is
> > > > > > > > > > going
> > > > > > > > > > > > > wrong,
> > > > > > > > > > > > > > > or
> > > > > > > > > > > > > > > > how, and have had no success in trying to narrow
> > it
> > > > > > down. If I
> > > > > > > > > > > comment
> > > > > > > > > > > > > out
> > > > > > > > > > > > > > > > the one line that clears Persist[100] after a
> > PCComm
> > > > > > command,
> > > > > > > > > > the
> > > > > > > > > > > > > problem
> > > > > > > > > > > > > > > > goes away entirely, and everything works
> > perfectly. If I
> > > > > > change
> > > > > > > > > > > that
> > > > > > > > > > > > > one
> > > > > > > > > > > > > > > > line to write *any* other location, like 99, or
> > 101, the
> > > > > > > > > > failure
> > > > > > > > > > > > > > > "signature"
> > > > > > > > > > > > > > > > changes - rather than crashing almost
> > immediately after
> > > > > > the
> > > > > > > > > > > Persist
> > > > > > > > > > > > > > > location
> > > > > > > > > > > > > > > > is written, the app continues to run normally
> > until I
> > > > > > close
> > > > > > > > > > it.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > But, if I then re-start the app without
> > first
> > > > > > > > > > disconnecting
> > > > > > > > > > > and
> > > > > > > > > > > > > > > > reconnecting the board, I get the debug dialog
> > again as
> > > > > > soon as
> > > > > > > > > > > the
> > > > > > > > > > > > > new
> > > > > > > > > > > > > > > app
> > > > > > > > > > > > > > > > instance recognizes the connection is available,
> > and
> > > > > > does its
> > > > > > > > > > > > > > > KM_Controller
> > > > > > > > > > > > > > > > initialization. I've stepped through all the
> > init code
> > > > > > and the
> > > > > > > > > > > > > > > constructors
> > > > > > > > > > > > > > > > on that second start-up, and whatever is going
> > wrong is
> > > > > > going
> > > > > > > > > > > wrong
> > > > > > > > > > > > > AFTER
> > > > > > > > > > > > > > > > they have all run, and I don't know how to stop
> > it at a
> > > > > > point
> > > > > > > > > > that
> > > > > > > > > > > > > would
> > > > > > > > > > > > > > > > give me any useful information about what is
> > going
> > > > > > wrong.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Not surprisingly, if I change the location
> > used
> > > > > > for
> > > > > > > > > > PComm (I
> > > > > > > > > > > > > shifted
> > > > > > > > > > > > > > > > it from Var 100 to 80), the problem follows it
> > to the
> > > > > > new
> > > > > > > > > > > location. So
> > > > > > > > > > > > > > > it's
> > > > > > > > > > > > > > > > not the specific location that's at issue, it
> > has to be
> > > > > > > > > > something
> > > > > > > > > > > > > > > connected
> > > > > > > > > > > > > > > > with that functionality. But we know the DSP
> > side works
> > > > > > fine,
> > > > > > > > > > and
> > > > > > > > > > > the
> > > > > > > > > > > > > PC
> > > > > > > > > > > > > > > > side isn't actually *doing* anything, other than
> > writing
> > > > > > that
> > > > > > > > > > one
> > > > > > > > > > > > > word. So
> > > > > > > > > > > > > > > > what the heck is really happening?
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > I've double-checked and all my
> > KM_Controller
> > > > > > accesses are
> > > > > > > > > > > > > surrounded
> > > > > > > > > > > > > > > > with locks, and I'm not doing anything that
> > requires
> > > > > > grabbing
> > > > > > > > > > the
> > > > > > > > > > > > > token
> > > > > > > > > > > > > > > (the
> > > > > > > > > > > > > > > > functions for doing Gather operations do use the
> > token,
> > > > > > but
> > > > > > > > > > those
> > > > > > > > > > > are
> > > > > > > > > > > > > > > > commented out now).
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > At the point where it's crashing, there
> > are three
> > > > > > threads
> > > > > > > > > > > > > running:
> > > > > > > > > > > > > > > > > > > 1) The main app thread
> > > > > > > > > > > > > > > > > > > 2) A thread running the WCF server for the
> > > > > > toolpath
> > > > > > > > > > display
> > > > > > > > > > > > > (which
> > > > > > > > > > > > > > > is
> > > > > > > > > > > > > > > > basically idle, since the toolpath window is not
> > open)
> > > > > > > > > > > > > > > > > > > 3) A BackgroundWorker thread doing most of
> > the GUI
> > > > > > > > > > updates
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > The app thread also has one Timer running,
> > at a
> > > > > > 100mSec
> > > > > > > > > > > rate,
> > > > > > > > > > > > > mostly
> > > > > > > > > > > > > > > > for periodically testing the connection, and
> > updating
> > > > > > the
> > > > > > > > > > > "connected"
> > > > > > > > > > > > > LED
> > > > > > > > > > > > > > > in
> > > > > > > > > > > > > > > > the GUI, and showing me the GUI state through a
> > set of
> > > > > > > > > > on-screen
> > > > > > > > > > > > > > > checkboxes.
> > > > > > > > > > > > > > > > This thread is the one that calls the PCComm
> > handler.
> > > > > > All Timer
> > > > > > > > > > > > > methods
> > > > > > > > > > > > > > > are
> > > > > > > > > > > > > > > > very simple and lightweight.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Any ideas how to proceed? I'd be happy to
> > post my
> > > > > > code if
> > > > > > > > > > > that
> > > > > > > > > > > > > would
> > > > > > > > > > > > > > > > help. I'm truly stuck on this one.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > > Regards,
> > > > > > > > > > > > > > > > > > > Ray L.
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
|
|
Group: DynoMotion |
Message: 3670 |
From: Andrew Ford |
Date: 2/1/2012 |
Subject: Re: Need Some Ideas.... |
So far I can't repro it right now, apparently, I'll grab it in the debugger if I see it again. I was exploring the hardware and I was printing out some of the values in the channels at runtime while turning an encoder, something similar to (on thread1, w/o any other threads running):
#include "KMotionDef.h" void main() { ch0->InputMode = ENCODER_MODE; ch0->InputChan0 = 0; for (;;) { printf("hello %f\n", ch0->Position);
Delay_sec(.1f); WaitNextTimeSlice(); } } Something I was doing was causing disconnections from the board and deadlocks in kmotion.exe. The deadlock looked very similar to the one you posted earlier in this thread.
Right now everything seems fine though, oh well... On Wed, Feb 1, 2012 at 11:15 AM, Tom Kerekes <tk@...> wrote:
Hi Andrew,
(again heldup as spam. I trimmed the message maybe that will help).
Yes please let me know what you find. How long does it take to happen? I haven't seen a problem like this. I still am not totally clear what you are doing. Are you running a .NET program at the same time as KMotion.
Thanks
TK
| | | | | | | | | | | | | | | | | | | | | | | |